question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compatible with norm colorbar ticks in matplotlib3.5+

See original GitHub issue

Description

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]

image

Actual behavior: [What actually happened]

image

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()

image

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:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
lukelbdcommented, Jan 14, 2022

Lol… had just decided to not be lazy and submit an issue myself (matplotlib/matplotlib#22232). Will delete it.

1reaction
zxdawncommented, Jan 14, 2022

Thanks, Luke. Created the issue.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found