1

I am working through the Qiskit tutorial textbook, and in Section 1.4 ('Single Qubit Gates'), I can't seem to plot vectors on the Bloch Sphere.

I am using Google Colab and am importing as:

!pip install qiskit
!pip install qiskit[visualization]
from qiskit import QuantumCircuit, assemble, Aer
from math import pi, sqrt
from qiskit.visualization import plot_bloch_multivector, plot_histogram
sim = Aer.get_backend('aer_simulator')

and then the following code is taken directly from the textbook:

qc = QuantumCircuit(1)
qc.x(0)
qc.save_statevector()
qobj = assemble(qc)
state = sim.run(qobj).result().get_statevector()
plot_bloch_multivector(state)

Yet doing this gives the error: " 'Arrow3D' object has no attribute '_path2d' ". Any help would be greatly appreciated.

Edit: Adding a line plt.show() no longer brings up an error message, but still no image shows.

Sam Frank
  • 31
  • 3
  • Upgrading matplotlib to 3.5 as per https://github.com/Qiskit/qiskit-terra/issues/7488 seems to work – Ben Jan 08 '22 at 12:25

2 Answers2

1

i had this same issue and upgrading matplotlib (to 3.5.1) fixed it for me

Lfenster
  • 11
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 08 '22 at 00:13
  • This worked for me as well. Just add "!pip install matplotlib --upgrade" to the top of the notebook – qzcx Jan 31 '22 at 17:37
0

I'm having the same problem. One workaround that I found is to use the Kaleidoscope package link. It's a visualization package developed by someone working at IBM. I actually like this as it uses Plotly for the figures.

import kaleidoscope.qiskit
from kaleidoscope import bloch_sphere

Then you can just type

bloch_sphere(state)
Karim
  • 449
  • 1
  • 5
  • 17