Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Open
Description
Bug summary
When trying to pass levels with unit-ful data to contour, the units are not correctly converted. In the example below I choose 7 contour levels from min(Z) to max(Z), and convert the units from kg to g. This should just change the units, not the locations where contour levels are drawn. The levels array is interpreted without units, and no contours are drawn.
Code for reproduction
importmatplotlib.pyplotaspltimportnumpyasnpimportpintureg=pint.UnitRegistry()ureg.setup_matplotlib()X,Y=np.meshgrid(np.linspace(-3,3,16),np.linspace(-3,3,16))Z= (1-X/2+X**5+Y**3)*np.exp(-X**2-Y**2)Z*=ureg.kglevels=np.linspace(np.min(Z),np.max(Z),7).to(ureg.g)fig,ax=plt.subplots()ax.contour(X,Y,Z,levels=levels)plt.show()
Actual outcome
Expected outcome
Additional information
No response
Operating system
No response
Matplotlib Version
3.7.0.dev1431+g526cb71e20.d20230123
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
None