Skip to content

Default norm when using levels in contour(f) produce non-intuitive behavior. #329

@Ockenfuss

Description

@Ockenfuss

Ultraplot ignores the vmin/vmax values, if the levels are explicitly set in contour plots.
This is documented behaviour.
However, I can't see the reason why this is the case?
Matplotlib is not ignoring vmin/vmax in contour plots, if they are explicitly set.
Only, if they are not given, the color boundaries are derived from the levels list.

from matplotlib.colors import Normalize
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import ultraplot as uplt

fig, ax=uplt.subplots()
x=np.linspace(-1,1,100)
y=np.linspace(-1,1,100)
X,Y=np.meshgrid(x,y)
Z=np.exp(-(X**2+Y**2))
im=ax.pcolormesh(X,Y,Z, cmap='turbo', alpha=0.6)
cs=ax.contour(X,Y,Z, levels=[0.3, 0.6, 0.9], cmap='turbo', vmin=0, vmax=1) # vmin/max are ignored here

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions