Compatible with norm colorbar ticks in matplotlib3.5+
See original GitHub issueDescription
The ticks of colorbar for manual levels are wrong for matplotlib3.5+.
Steps to reproduce
import proplot as pplt
import matplotlib
import numpy as np
crf_bounds = np.array([0, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.97, 0.98, 0.99, 1.0])
norm = matplotlib.colors.BoundaryNorm(boundaries=crf_bounds, ncolors=256)
x = y = np.array([-10, -5, 0, 5, 10])
np.random.seed(20)
data = np.random.uniform(0,1,(4,4))
fig, axs = pplt.subplots()
m = axs.pcolormesh(x, y, data, cmap='RdYlGn', norm=norm)
axs.colorbar([m])
Expected behavior: [What you expected to happen]
Actual behavior: [What actually happened]
Equivalent steps in matplotlib
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
crf_bounds = np.array([0, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.97, 0.98, 0.99, 1.0])
norm = matplotlib.colors.BoundaryNorm(boundaries=crf_bounds, ncolors=256)
x = y = np.array([-10, -5, 0, 5, 10])
np.random.seed(20)
data = np.random.uniform(0,1,(4,4))
plt.pcolormesh(x, y, data, cmap='RdYlGn', norm=norm)
plt.colorbar()
Proplot version
Paste the results of import matplotlib; print(matplotlib.__version__); import proplot; print(proplot.version)
here.
3.5.1
0.9.5.post105
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
matplotlib.colorbar — Matplotlib 3.6.2 documentation
The mappable whose colormap and norm will be used. To show the under- and over- value colors, the mappable's norm should be specified...
Read more >Wrong minor colorbar ticks in the presence of BoundaryNorm ...
Bug summary. The minor colorbar ticks are messed up for matplotlib3.5+. But, it works well for v3.4.3. ; Code for reproduction. import matplotlib...
Read more >matplotlib colorbar tick label outside bug - Stack Overflow
... import random # Make plot with horizontal colorbar fig, ax = plt.subplots() data = random((250,250)) + 3.5 norm = matplotlib.colors.
Read more >Chapter 4. Visualization with Matplotlib - O'Reilly
Matplotlib is a multiplatform data visualization library built on NumPy arrays, … ... cmap = 'Blues' ) cb = plt . colorbar (...
Read more >matplotlib - freshcode.club
Color sequence registry. - Colormap method for creating a different lookup table size. - Setting norms with strings. Titles, ticks, and labels.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Lol… had just decided to not be lazy and submit an issue myself (matplotlib/matplotlib#22232). Will delete it.
Thanks, Luke. Created the issue.