Qiskit-terra: Jupyter Notebook: Stretched Bloch and Q-Spheres

Created on 21 Jul 2020  路  7Comments  路  Source: Qiskit/qiskit-terra


Information

  • Qiskit Terra version: 14.2
  • Matplotlib version: 3.3.0
  • Python version: 3.7.7
  • Operating system: macOS

What is the current behavior?

E58F2CA8-49F3-419B-82CB-654332C5678E

When I create a Bloch or Q-Sphere, the drawing displayed is horizontally stretched.

Steps to reproduce the problem

  1. Open a Jupyter Notebook
  2. Type the following into a cell:
from numpy import sqrt
from qiskit.visualization import plot_bloch_multivector

plot_bloch_multivector([1/sqrt(2), 1/sqrt(2)])
  1. Run the cell

What is the expected behavior?

I would expect the spheres to be shaped like spheres instead of ellipsoids.

Suggested solutions

Is it possible the backend (matplotlib?) needs to be updated?

bug

Most helpful comment

Hey, looks like this has not been fixed yet. Mind if I take a look at this?

All 7 comments

What's your matplotlib version? Cause mine is 3.2.2 and Bloch shpere is fine for me.
Additionally, did you try adding %matplotlib inline or infact, try adding figsize param: plot_bloch_multivector([1/sqrt(2), 1/sqrt(2)], figsize=(10,10))?

@obliviateandsurrender I'm running matplotlib version 3.3.0 (so this might be a version issue?) and neither figsize=(10,10) nor %matplotlib inline fixed the drawing.

Screen Shot 2020-07-21 at 12 28 45 PM

I can also replicate the issue with matplotlib 3.3.0 but not with 3.2.2.

Likely due to https://matplotlib.org/3.3.0/users/whats_new.html#axes3d-no-longer-distorts-the-3d-plot-to-match-the-2d-aspect-ratio

@gschaffner Do you think creating a default argument for set_box_aspect would fix the distortion?

Hey, looks like this has not been fixed yet. Mind if I take a look at this?

@e-eight yes please do! i hope you can figure it out but let me know if i can help with anything

Cool. I'll let you know what I find.

Was this page helpful?
0 / 5 - 0 ratings