Closed zxdawn closed 4 years ago
This was due to the fact that DiscreteNorm
(used for all colormaps in proplot) requires at least 2 levels. I added an edge condition to fix it -- the result of your example is now a single contour whose color is the central color of the specified (or default) colormap, which matches the behavior in matplotlib.
Example:
import proplot as plot
import pandas as pd
import numpy as np
fig, axs = plot.subplots()
state = np.random.RandomState(51423)
data = state.rand(6, 6)
data = pd.DataFrame(data, index=pd.Index(['a', 'b', 'c', 'd', 'e', 'f']))
# Line contours with labels
axs.contour(
data.cumsum(axis=1) - 2,
cmap='grays',
levels=[0],
)
axs.format(title='Line contour plot with labels')
Thanks Luke! Nice fix ;)
Description
contour
doesn't work when only one level is available inlevels
.Steps to reproduce
Expected behavior: Just like the color is specified:
Actual behavior:
Proplot version
0.6.3