-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
contourf error #40
Comments
Hi @quai20 - can you provide a short example demonstrating this? |
of course, here's my example : `#READING my_nc_file = 'NRTOAGL01_20150315_fld_TEMP.nc' LON=fh.variables['longitude'][:] #PLOTTING #contouring #plt.show() The data file is here if needed : https://cloud.ifremer.fr/index.php/s/moxThfGrVPQaHWi |
I am running into the same issue now. I can plot the contour just fine, contourf works with pyplot, but gives the following error with mplleaflet.
Code: import mplleaflet
from matplotlib.colors import LinearSegmentedColormap
import matplotlib.pyplot as plt
import pygrib
import single_point
files = ["gfs.t12z.pgrb2.0p25.f006",
"hrrr.t23z.wrfsfcf02.grib2",
"hrrr.t01z.wrfsfcf06.grib2"]
hrrr = pygrib.open(files[2])
hrrr.seek(0)
ref = hrrr.select(name="Maximum/Composite radar reflectivity")[0]
radar = ref.values
lats, lons = ref.latlons()
clevs = [20,30,40,50,60,70]
cmap = LinearSegmentedColormap.from_list("my_colormap",
[[0.063, 0.306, 0.545],
[0.000, 0.804, 0.000],
[0.933, 0.933, 0.000],
[0.804, 0.000, 0.000],
[0.000, 1.000, 1.000]],
N=5,
gamma=1.0)
cs = plt.contourf(lons, lats, radar, clevs, cmap=cmap)
#plt.show()
mplleaflet.show() Seems as if a ring isn't completed and is throwing an error perhaps? contourf plotting with pyplot |
Got the same error. Added this to the code to bypass it.
|
The same issue here for me.. |
@jwass , please make changes in the code |
Is this being worked on? I have almost the exact same problem. I'm trying to plot rings, and I get the error For reference, this is what it looks like in matplotlib: And this is the error:
And this is the code I'm using to generate it: import matplotlib.pyplot as plt
from matplotlib.patches import Wedge
from matplotlib.collections import PatchCollection
import mplleaflet
lon = -77.036451
lat = 38.897503
patches = []
ring = Wedge((lon, lat), 10, 0, 360, width=4)
patches.append(ring)
p = PatchCollection(patches, alpha=0.6)
fig, ax = plt.subplots()
ax.add_collection(p)
ax.set_xlim([-87.5, -65])
ax.set_ylim([27.5, 50])
# mplleaflet.show(fig = ax.figure)
plt.show() The solution given above does not work, since the If Matplotlib is using Bezier curves it's probably a good idea for mplleaflet to support them as well. Edit: I did some light debugging. The pathcodes that gets passed to
and the data is this (abbreviated):
The main thing to notice is that the first command is the You can also note that the I tried changing def iter_rings(data, pathcodes):
ring = []
i = 0
# TODO: Do this smartly by finding when pathcodes changes value and do
# smart indexing on data, instead of iterating over each coordinate
for code in pathcodes:
if code == 'M':
# Emit the path and start a new one
if len(ring):
yield ring
ring = [data[i:i+2]]
i += 2
elif code == 'L':
ring.append(point)
elif code == 'Z':
ring.append([])
elif code == 'C':
params = []
params.extend(data[i:i+2])
params.extend(',')
i += 2
params.extend(data[i:i+2])
params.extend(',')
i += 2
params.extend(data[i:i+2])
i += 2
ring.append(params)
else:
raise ValueError('Unrecognized code: {}'.format(code))
if len(ring):
yield ring When I look at the HTML output it seems as if the data gets divided into pairs somewhere anyway:
|
@disarticulate Can you post a pull request with the change to fix this? |
ask and you shall receive |
@disarticulate You rock! Thanks. |
I hope I don't offend anyone, but #51 is not a fix to this issue. I left a comment there as well, but I thought my lengthy comment above in this issue explained pretty well what was wrong. The main issue that should be addressed is that SVG contain codes that take a different amount of parameters, not only 2 like |
Hi,
Really great work it's an amazing tool. I managed to make the contour example work and one of my contour plot also. But when I switch the plot to contourf (wich is ok with my plt.show()), mplleaflet crashes with this error :
Any ideas ?
The text was updated successfully, but these errors were encountered: