You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ax passed by proplot is GeoAxes instead of GeoAxesSubplot.
proplot doesn't accept matplotlib.colors.BoundaryNorm. Instead, it uses BinNorm.
Code
proplot version
import cartopy.crs as ccrs
import proplot as plot
from pycwr.draw.RadarPlot import Graph, GraphMap
from pycwr.io.auto_io import radar_io
proj = ccrs.PlateCarree()
f, axs = plot.subplots(proj=proj)
dir = '/yin_raid/xin/data/radar/guangzhou/'
file = "Z_RADR_I_Z9200_20160506100000_O_DOR_SA_CAP.bin.bz2"
data = radar_io(dir+file)
NRadar = data.ToPRD()
graph = GraphMap(NRadar, ccrs.PlateCarree())
ax=axs[0]
graph.plot_crf_map(ax)
matplotlib version
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from pycwr.draw.RadarPlot import Graph, GraphMap
from pycwr.io.auto_io import radar_io
dir = '/yin_raid/xin/data/radar/guangzhou/'
file = "Z_RADR_I_Z9200_20160506100000_O_DOR_SA_CAP.bin.bz2"
data = radar_io(dir+file)
NRadar = data.ToPRD()
lon_min = 111.5; lon_max = 115
lat_min = 22.5; lat_max = 25
ax = plt.axes(projection=ccrs.PlateCarree())
graph = GraphMap(NRadar, ccrs.PlateCarree())
graph.plot_crf_map(ax)
ax.set_xlim([lon_min, lon_max])
ax.set_ylim([lat_min, lat_max])
Error of proplot version
Error 1
Traceback (most recent call last):
File "crf.py", line 21, in <module>
graph.plot_crf_map(ax)
File "/yin_raid/xin/miniconda3/envs/pycwr/lib/python3.7/site-packages/pycwr-0.2.14-py3.7-linux-x86_64.egg/pycwr/draw/RadarPlot.py", line 368, in plot_crf_map
assert isinstance(ax, cartopy.mpl.geoaxes.GeoAxesSubplot), "axes is not cartopy axes!"
AssertionError: axes is not cartopy axes!
Error 2
File "crf.py", line 20, in <module>
graph.plot_crf_map(ax)
......................
File "/yin_raid/xin/miniconda3/envs/pycwr/lib/python3.7/site-packages/proplot/styletools.py", line 2614, in __init__
f'Normalizer cannot be an instance of '
ValueError: Normalizer cannot be an instance of matplotlib.colors.BoundaryNorm.
Solution of proplot version
Solution 1
Use tuple in isinstance:
assert isinstance(ax, (cartopy.mpl.geoaxes.GeoAxes, cartopy.mpl.geoaxes.GeoAxesSubplot)), "axes is not cartopy axes!"
Solution 2
Use levels instead of norm for proplot:
pm = ax.pcolormesh(lon, lat, radar_data, transform=self.transform, cmap=cmap, levels=levels, zorder=4, **kwargs)
Output Figures
matplotlib version
proplot version
Final solution
We need to find a better solution of supporting both matplotlib and proplot.
The text was updated successfully, but these errors were encountered:
zxdawn
changed the title
Support GeoAxes passed by proplot
Support proplot
Mar 15, 2020
Problem
GeoAxes
instead ofGeoAxesSubplot
.proplot
doesn't acceptmatplotlib.colors.BoundaryNorm.
Instead, it usesBinNorm
.Code
proplot version
matplotlib version
Error of proplot version
Error 1
Error 2
Solution of proplot version
Solution 1
Use tuple in
isinstance
:Solution 2
Use
levels
instead ofnorm
for proplot:Output Figures
matplotlib version
proplot version
Final solution
We need to find a better solution of supporting both matplotlib and proplot.
The text was updated successfully, but these errors were encountered: