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
Really enjoying xarray! Converting all my scripts and on the quest to simplify my plotting.
For my current project I need loads of maps and generally add a land/ ocean layer and country boundaries as well as an default extent to the plot axes...
I use for instance a extra layer like this:
import cartopy.crs as cars
import cartopy.feature as feature
# default map backgrounds
countries = cfeature.NaturalEarthFeature(
category='cultural',
name='admin_0_countries',
scale='50m',
facecolor='none')
This is a bit clumsy at the moment - I basically define the axes for each subplot (say 1..12 month), loop over them, select the axis and add them with ax.set_extent(), ax.add_feature() etc...
This works, but I'd rather use the plot function within DataArray or DataSet... Also thinking about using FacetGrid instead of doing it manually.
I thought about using the new decorators to patch this onto a custom plot directive but my Python is not really advanced enough for decorators and the inner functioning of array it seems...
@xr.register_dataarray_accessor('map')
class MapDecorator(object):
def __init__(self, xarray_obj):
self._obj = xarray_obj
def plot(self, **kwargs):
"""Plot data on a map."""
print "my decorator"
#ax.set_extent([102, 110, 8, 24])
## add map elements
#ax.add_feature(countries, edgecolor='gray') # country borders
#ax.add_feature(ocean) # ocean
#ax.coastlines(resolution='50m') # coastlines
p = self._obj.plot( kwargs )
return p
Not sure if this is a valid path or how one would do that? I would also like to have some default arguments (projection=)
Cheers,
Christian
The text was updated successfully, but these errors were encountered:
I wrote a function that I call geocolormesh which automatically creates cartopy GeoAxes for single plots and for FacetGrids. This may go in the direction of what you would like to get. I find this very convenient for fast plotting - once I do the final plots some more work is needed. Unfortunately this is not possible without some changes* in the default plotting function (and also in facet grid). Thus, I added a pull request. Not sure what the developers will think of this.
*Because it is not possible to change the projection of axes once they are created.
In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity
If this issue remains relevant, please comment here; otherwise it will be marked as closed automatically
Hi.
Really enjoying xarray! Converting all my scripts and on the quest to simplify my plotting.
For my current project I need loads of maps and generally add a land/ ocean layer and country boundaries as well as an default extent to the plot axes...
I use for instance a extra layer like this:
An example from a class I work on right now:
This is a bit clumsy at the moment - I basically define the axes for each subplot (say 1..12 month), loop over them, select the axis and add them with ax.set_extent(), ax.add_feature() etc...
This works, but I'd rather use the plot function within DataArray or DataSet... Also thinking about using FacetGrid instead of doing it manually.
I thought about using the new decorators to patch this onto a custom plot directive but my Python is not really advanced enough for decorators and the inner functioning of array it seems...
Not sure if this is a valid path or how one would do that? I would also like to have some default arguments (projection=)
Cheers,
Christian
The text was updated successfully, but these errors were encountered: