Skip to content

Colormap modified by proplot.imshow (unexpected) #416

Open
@lkugler

Description

@lkugler

Hi, thank you for this tool. I think it's great as it saves a lot of time. Sometimes though, there are unexpected features (bugs?)

Description

The colormap is weird if used with proplot.

Steps to reproduce

Compare these two plots. The colormap is changed when used via proplot.

import numpy as np
import matplotlib.pyplot as plt

# load a colormap
cmap = 'ir_rgbv'
from metpy.plots import colortables
cmap = colortables.get_colortable(cmap)

# some random data
data = np.random.rand(50, 50)

# test with matplotlib
fig, ax = plt.subplots(figsize=(5, 5))
m = ax.imshow(data, cmap=cmap)
cb = fig.colorbar(m, ax=ax)
ax.set_title(cmap)
fig.savefig('test_mpl.png', dpi=100)

# test with proplot
import proplot as pplt
fig, ax = pplt.subplots(nrows=1, ncols=1, figsize=(5, 5))
m = ax.imshow(data, cmap=cmap)
cb = fig.colorbar(m, ax=ax)
ax.set_title(cmap)
fig.savefig('test_proplot.png', dpi=100)

Expected behavior: The output png should be identical

Actual behavior: Only part of the colormap is used.

Equivalent steps in matplotlib

See above.

Proplot version

0.9.5.post332

My workaround/quickfix is

wv_cols = colortables.get_colortable('ir_rgbv').reversed()
from matplotlib import colors
cmap = colors.LinearSegmentedColormap.from_list('ir_rgbv', wv_cols.colors)

import proplot as pplt
fig, ax = pplt.subplots(nrows=1, ncols=1, figsize=(5, 5))
m = ax.imshow(data, cmap=cmap)
cb = fig.colorbar(m, ax=ax)
ax.set_title(cmap)

fig.savefig('test_proplot.png', dpi=100)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions