Bug contourf
See original GitHub issueDescription
I’m running into an error after upgrading the proplot version . The error occurs when using contourf, the error message is KeyError: ‘red’
Steps to reproduce
# your code here
# we should be able to copy-paste this into python and exactly reproduce your bug
import proplot as plot
import matplotlib.pyplot as plt
import numpy as np
f, axs = plot.subplots(ncols=1, nrows=1)
#generate random data
data=np.ones((180,360))
data[20:80,80:150]+=1
x=np.arange(0,360,1)
y=np.arange(0,180,1)
axs.contourf(x,y,data,cmap=plt.cm.coolwarm)
plt.show()
Expected behavior: A simple contourf plot
Actual behavior: An error message occured and the plot was not produced
Equivalent steps in matplotlib
Pretty sure its Proplot. With matplotlib this works
import matplotlib.pyplot as plt
import numpy as np
f,axs=plt.subplots()
#generate random data
data=np.ones((180,360))
data[20:80,80:150]+=1
x=np.arange(0,360,1)
y=np.arange(0,180,1)
axs.contourf(x,y,data,cmap=plt.cm.coolwarm)
plt.show()
Proplot version
Matplotlib: 3.4.1 Proplot: 0.9.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
matplotlib.pyplot.contourf — Matplotlib 3.6.2 documentation
It is an error to use vmin/vmax when a norm instance is given (but using a str norm name together with vmin/vmax is...
Read more >Filled 2-D contour plot - MATLAB contourf - MathWorks
This MATLAB function creates a filled contour plot containing the isolines of matrix Z, where Z contains height values on the x-y plane....
Read more >some contourf levels not drawn in Orthographic projection (are ...
I think this is a very serious bug. This makes it impossible to reliably produce filled contours when looking at the poles. Is...
Read more >GNU Octave - Bugs: bug #62874, text in contourf is not well ...
Plotting a contourf and adding text on isolinee withe clable results in unreadable/ bad readable values. Anonymous. (-)Attached Files(+)Attached ...
Read more >pyplot.contourf() returns error when specified levels argument
0. I'm trying to make a contour plot in Python using the matplotlib.pyplot.contourf() function, and it works perfectly like this ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No problem. Thanks for your clarification – after that I found the solution relatively quickly (182a186).
The
Colormap
constructor function converts input native matplotlib colormaps to proplot’s colormap subclasses (i.e.ListedColormap
toDiscreteColormap
,LinearSegmentedColormap
toContinuousColormap
). There was a bug in the conversion process that caused erasure of the originalsegmentdata
. This happened the first time the native matplotlib colormap was passed throughColormap
(i.e., the firsthist2d
call). To fix this, I simply make sure to copy the native colormap segment data dictionary before using it for the new colormap.Thanks @matthias-k for digging further and @lukelbd for addressing the issue so quickly!