-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Milestone
Description
Bug summary
When saving a figure with a colorbar and a mappable using a TwoSlopeNorm, it sometimes results in posx and posy should be finite values. The saved figure then lacks of a label for the colorbar.
Note that:
- you need to specify a
vmaxsmaller than or equat to0.9989999999999999 - this looks independent of the max and min values of
Z. Tested withZ = 10000*(X**3 - Y**4)andZ = (X**3 - Y**4)/10000
it dos not happen:
- if the figure is not saved but only shown
- with previous versions of matplotlib
Code for reproduction
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.colors as colors
x = np.linspace(0, 1, 100)
y = x.copy()
X, Y = np.meshgrid(x, y)
Z = X**3 - Y**4
divnorm = colors.TwoSlopeNorm(vcenter=0, vmax=0.1)
fig = plt.figure()
c = plt.pcolormesh(x, y, Z, cmap='seismic', norm=divnorm)
plt.colorbar(c, label='Velocity [cm/s]')
plt.savefig('Spatio_temporal_velocity.png')
plt.show()Actual outcome
Expected outcome
It should display the colorbar label, and not return in the terminal posx and posy should be finite values.
Additional information
- you need to specify a
vmaxsmaller than or equat to0.9989999999999999 - this looks independent of the max and min values of
Z. Tested withZ = 10000*(X**3 - Y**4)andZ = (X**3 - Y**4)/10000
it dos not happen:
- if the figure is not saved but only shown
- with previous versions of matplotlib
Operating system
Ubuntu 20
Matplotlib Version
3.5.0
Matplotlib Backend
QtAgg
Python version
3.8.10
Jupyter version
No response
Installation
pip
Metadata
Metadata
461A
No one assignedNo typeNo projectsNone yetNo branches or pull requests
