-
Notifications
You must be signed in to change notification settings - Fork 83
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
- The ax passed by proplot is
GeoAxesinstead ofGeoAxesSubplot. proplotdoesn't acceptmatplotlib.colors.BoundaryNorm.Instead, it usesBinNorm.
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request

