Zorder for metpy.BarbPlot #2746
-
Hey folks, I am plotting some data onto a CartoPy map but when adding some of the CartoPy features such as lakes, in particular, sit on top of the wind barbs. I have looked through the documentation and have tried setting a zorder, but it doesn't seem to be a feature for metpy.BarbPlot? Any thoughts? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Well that's problematic. Yeah, we don't expose zorder (that's pretty nitty gritty) in the declarative, but that's not great here. Here's a work-around: import xarray as xr
from metpy.cbook import get_test_data
from metpy.plots import ContourPlot, ImagePlot, MapPanel, PanelContainer, BarbPlot
from metpy.units import units
# Use sample NARR data for plotting
narr = xr.open_dataset(get_test_data('narr_example.nc', as_file_obj=False))
contour = ContourPlot()
contour.data = narr
contour.field = 'Temperature'
contour.level = 850 * units.hPa
contour.linecolor = 'red'
contour.contours = 15
barb = BarbPlot()
barb.data = narr
barb.field = ('u_wind', 'v_wind')
barb.level = 850 * units.hPa
barb.skip = (10, 10)
panel = MapPanel()
panel.area = 'us'
panel.layers = ['coastline', 'borders', 'states', 'rivers', 'ocean', 'land', 'lakes']
panel.title = 'NARR Example'
panel.plots = [contour, barb]
pc = PanelContainer()
pc.size = (10, 8)
pc.panels = [panel]
pc.save('temp.png') # Triggers creation of objects
barb.handle.set_zorder(10)
pc.show() The @kgoebber Thoughts? I'm wondering if for |
Beta Was this translation helpful? Give feedback.
Well that's problematic. Yeah, we don't expose zorder (that's pretty nitty gritty) in the declarative, but that's not great here. Here's a work-around: