Skip to content

norm ignored when (when clipping) for coloring scatter plots; normalizer is modified #75

@Jhsmit

Description

@Jhsmit

when passing a norm to scatter / pcolor, the norm is ignored for coloring but also its vmin/vmax values are modified

import numpy as np
import ultraplot as uplt
import matplotlib.pyplot as plt

x = np.arange(10)
y = x**2
c = y

cmap = uplt.Colormap("viridis")
norm = uplt.Norm("linear", 0, 10)
fig, ax = uplt.subplots()
ax.scatter(x, y, c=c, cmap=cmap, norm=norm)
print(norm.vmin, norm.vmax)


fig, ax = plt.subplots()
norm = uplt.Norm("linear", 0, 10)
ax.scatter(x, y, c=c, cmap=cmap, norm=norm)
>>> 0.0 81.0

ultraplot result

Image

matplotlib result

Image

See also the discussion on the proplot github: proplot-dev/proplot#400

A workaround is to pass vmin, vmax directly.
norm not correctly applying colors I can live with but the modification of the norm object is unexpected thus dangerous

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions