Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug summary
When using logarithmic scaling of the data with 2D plots, the ticks for the colorbar are not written in scientific notation. Prior to Matplotlib 3.5.0 (e.g. 3.4.3), scientific notation was used, as one would expect. The problem persists in 3.6.
Code for reproduction
# Sample code for 2D plotting with log scaling,# with the log scaling implemented# using two different methods.importnumpyasnpimportmatplotlibimportmatplotlib.pyplotaspltn=100np.random.seed(42)x=np.random.random(n)y=np.random.random(n)z=np.logspace(np.log10(1e-7),np.log10(1e+7),n)fig,axes=plt.subplots(2,1)tcs=axes[0].tricontourf(x,y,z,norm=matplotlib.colors.LogNorm(vmin=z.min(),vmax=z.max()),)cbar=fig.colorbar(tcs,ax=axes[0])tcs=axes[1].tricontourf(x,y,z,locator=matplotlib.ticker.LogLocator(),)cbar=fig.colorbar(tcs,ax=axes[1])plt.savefig('test.png')
Actual outcome
Here is the outcome of the above in Matplotlib 3.5.0 or 3.6.0 (the results are identical). The image properly shows logarithmic values, and the colorbar ticks are in log scale as well, but the colorbar tick labels are not written using scientific notation. One major drawback is that all tics but the highest two gets written as0.00
, while they are really0.001
,0.0001
, etc.
Expected outcome
Same as above but run with Matplotlib 3.4.3. Both methods work to produce scientific notation, as desired.
Operating system
Linux Mint 20
Matplotlib Version
As described above
Matplotlib Backend
Agg and Qt5Agg
Python version
3.8.5 and 3.9.9
Installation
from source (.tar.gz)