Qiskit-terra: plot_state_city() cuts off x/y axes tick labels

Created on 27 Feb 2019  路  5Comments  路  Source: Qiskit/qiskit-terra


Information

  • Qiskit Terra version: 0.8
  • Python version: 3.6.8
  • Operating system: macOS 10.14.3

What is the current behavior?

plot_state_city() cuts off x/y axes tick labels

plot_state_city() is defined here

Steps to reproduce the problem

import numpy as np
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import execute
from qiskit.tools.visualization import plot_state_city
import matplotlib.pyplot as plt
q = QuantumRegister(3, 'q')
circ = QuantumCircuit(q)
circ.h(q[0])
circ.cx(q[0], q[1]).
circ.cx(q[0], q[2])
from qiskit import BasicAer
backend = BasicAer.get_backend('statevector_simulator')
job = execute(circ, backend)
result = job.result()
outputstate = result.get_statevector(circ)
plot_state_city(outputstate)

What is the expected behavior?

The axes tick labels should not be cutoff.

Suggested solutions

https://stackoverflow.com/questions/6774086/why-is-my-xlabel-cut-off-in-my-matplotlib-plot

bug

All 5 comments

Yeah I would just add a tight_layout() call to the end of the function. That's normally how I solve the cut off label problem

For reference the output with the labels cut off looks like this: test

Hmm, actually I just checked the code we have a tight_layout() call in there already: https://github.com/Qiskit/qiskit-terra/blob/master/qiskit/tools/visualization/_state_visualization.py#L339 so something else is going on. I'll have to dig more deeply.

I think this issue has been resolved with #3123. At least for me the ticks are not cut off anymore. (The suggested solution from the stackexchange website to simply add a small offset
plt.subplots_adjust(bottom=0.15)
worked in connection with the tight_layout() call as well.)

solved via #3123. Feel free to reopen if that's not the case.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

1ucian0 picture 1ucian0  路  6Comments

chowington picture chowington  路  4Comments

jaygambetta picture jaygambetta  路  6Comments

Sridhar-Majety-UCD picture Sridhar-Majety-UCD  路  3Comments

1ucian0 picture 1ucian0  路  5Comments