Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matplotlib update broke qpt_plot_combined #2233

Closed
theodotk opened this issue Sep 27, 2023 · 1 comment
Closed

Matplotlib update broke qpt_plot_combined #2233

theodotk opened this issue Sep 27, 2023 · 1 comment

Comments

@theodotk
Copy link
Contributor

Bug Description

It seems that in new matplotlib version they separated classes Axes and Axes3d, so some plotting functions that have 3d aspects don't work as expected anymore. See example in the code below.

Code to Reproduce the Bug

from qutip import qpt_plot_combined
qpt_plot_combined(np.eye(4), [["I", "X", "Y", "Z"]])

Code Output

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[8], line 2
      1 from qutip import qpt_plot_combined
----> 2 qpt_plot_combined(np.eye(4), [["I", "X", "Y", "Z"]])

File ~\AppData\Local\pypoetry\Cache\virtualenvs\photonic-component-simulator-biULA8HA-py3.9\lib\site-packages\qutip\tomography.py:143, in qpt_plot_combined(chi, lbls_list, title, fig, ax, figsize, threshold)
    140 if not title:
    141     title = r"$\chi$"
--> 143 matrix_histogram_complex(chi, xlabels, xlabels, title=title, ax=ax,
    144                          threshold=threshold)
    146 return fig, ax

File ~\AppData\Local\pypoetry\Cache\virtualenvs\photonic-component-simulator-biULA8HA-py3.9\lib\site-packages\qutip\visualization.py:820, in matrix_histogram_complex(M, xlabels, ylabels, title, limits, phase_limits, colorbar, fig, ax, threshold)
    818 # x axis
    819 xtics = -0.5 + np.arange(M.shape[0])
--> 820 ax.axes.w_xaxis.set_major_locator(plt.FixedLocator(xtics))
    821 if xlabels:
    822     nxlabels = len(xlabels)

AttributeError: 'Axes3D' object has no attribute 'w_xaxis'

Expected Behaviour

There should be a plot and not an error

Your Environment

QuTiP vesion: '4.7.3'
matplotlib version: '3.8.0'

Additional Context

No response

@nleehone
Copy link

nleehone commented Oct 10, 2023

This seems to be because of this change: https://matplotlib.org/3.8.0/api/prev_api_changes/api_changes_3.8.0.html#axes3d

The solution from the docs:

The w_xaxis, w_yaxis, and w_zaxis attributes are now removed. Instead use xaxis, yaxis, and zaxis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants