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.

`vmax` has no effects without `vmin`

See original GitHub issue

Description

In the old version of proplot, once I set the vmax, the threshold of the plotting figure will change.

But I have to set both vmin and vmax to make it work for the new version.

Steps to reproduce

import proplot as pplt
import numpy as np

# Sample data
state = np.random.RandomState(51423)
x = y = np.array([-10, -5, 0, 5, 10])
data = state.rand(y.size, x.size)

# Figure
fig = pplt.figure(refwidth=2.3, share=False)
axs = fig.subplots()

m = axs.pcolormesh(x, y, data, vmax=1.35)
axs.colorbar([m], loc='r')

Expected behavior: image

Actual behavior: [What actually happened] image

Proplot version

Paste the results of import matplotlib; print(matplotlib.__version__); import proplot; print(proplot.version)here.

3.3.4
0.8.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
lukelbdcommented, Jan 25, 2022

Looks like I missed your last comment.

This actually isn’t a bug – it’s a result of proplot feeding vmin and vmax into an algorithm similar to matplotlib’s _autolev algorithm used to determine contour levels. The algorithm tries to generate nice levels and in general does not guarantee an exact match to vmin and vmax (the idea being that vmin and vmax are very often automatically chosen from the data (by default, or when using the robust keyword), and you don’t want to have a discrete level boundary at e.g. 3.12349...).

Although the behavior shown in your example is kind of silly, since vmax=3 is obviously “nice” and shouldn’t be truncated. Will take a look at the algorithm. Note that repeating your example with discrete=False results in an exact match, because “non-discrete” levels do not have to be ticked at vmin/vmax:

import proplot as pplt
import numpy as np

# Sample data
state = np.random.RandomState(51423)
x = y = np.array([-10, -5, 0, 5, 10])
data = state.rand(y.size, x.size)

# Figure
fig = pplt.figure(refwidth=2.3, share=False)
axs = fig.subplots()

m = axs.pcolormesh(x, y, data, vmin=0, vmax=3, discrete=False)
axs.colorbar([m], loc='r')

tmp

1reaction
zxdawncommented, Oct 12, 2021

@lukelbd This issue still exists in version 0.9.3:

import proplot as pplt
import numpy as np

# Sample data
state = np.random.RandomState(51423)
x = y = np.array([-10, -5, 0, 5, 10])
data = state.rand(y.size, x.size)

# Figure
fig = pplt.figure(refwidth=2.3, share=False)
axs = fig.subplots()

m = axs.pcolormesh(x, y, data, vmin=0, vmax=3)
axs.colorbar([m], loc='r')

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

`vmax` has no effects without `vmin` · Issue #276 · proplot-dev ...
Description In the old version of proplot, once I set the vmax, the threshold of the plotting figure will change. But I have...
Read more >
vmin, vmax not changing the display range in plt.imshow ...
I'm doing some manipulation with images and need the image to be displayed correctly exactly as it is in the array.
Read more >
ImageNormalize — Astropy v5.2
If vmin and/or vmax is not given, they are initialized from the minimum and maximum value, respectively, of the first input processed; i.e.,...
Read more >
Using vmin and vmax does not change anything for my plots
I did not change vmin and vmax, to plot another set of data that has a different (LOWER) minimum and maximum.
Read more >
vw, vh, vmin, vmax Unit Support - Litmus
Hi there! Has anyone ever tried to use vw, vh, vmin, vmax units in their email design/dev travels? I'm specifically interested in whether...
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