0

System Informations

Qiskit version: 0.17.0
Python version: 3.7.7
Operating system: Windows 10 home x64

What is the current behavior?

I am using spyder 4.1.1 on Anaconda and any time I try to plot data it does not show up. The code runs with no errors but the plot it self does not appear anywhere.

Steps to reproduce the problem

Running the code listed below which is from the IBMQ website:

import numpy 
import qiskit as qc 
from qiskit import QuantumCircuit, execute, Aer
import matplotlib
from qiskit.visualization import plot_state_city

circ = qc.QuantumCircuit(3)

circ.h(0)
circ.cx(0,1)
circ.cx(0,2)
print(circ.draw())
backend = Aer.get_backend('statevector_simulator')
job = execute(circ, backend)
result = job.result()
outputstate = result.get_statevector(circ, decimals=3)
print(outputstate)
plot_state_city(outputstate)

What is the expected behavior?

for the plot state city plot to show up in the console or somewhere else

Suggested solutions

I tried using both matplotlib.pylot.show() and matplotlib.pyplot.draw()

tinjinkin
  • 3
  • 1

3 Answers3

0

This may be because the plots don't show in spyder by default. If you run this code in a Jupyter Notebook the plots should show up just fine!

met927
  • 301
  • 4
  • 8
  • I understand this, I do prefer spyder over Jupyter. is there anyway to make it work on spyder? if not that is fine but i thought i should ask. – tinjinkin May 05 '20 at 01:34
  • I have never used spyder before I am afraid so I can't help any further. If when normally using matplot the plots just show up, but here they don't, then I think that may be an issue with qiskit. You can raise it as an issue here https://github.com/Qiskit/qiskit-terra/issues – met927 May 05 '20 at 09:52
0

Try follow the instructions under "Spyder plots in separate windows" here. Then you can also call circ.draw(output='mpl') to draw the circuit in a window. Hope this helps.

kgi
  • 16
  • 2
0

To print your circuit, you have to type print(name of the circuit) so in your case type print(circ).

lisa
  • 3
  • 1