-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Enhanced plotting option (latex backend and/or unit change) #4414
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
Comments
Thanks a lot for this suggestion! I'll let the others chime in as well, but there are a few things to consider here:
|
|
Hi @fmaussion and @keewis, Thank you for your comments, I agree that these changes are opinionated, and so probably inappropriate for inclusion in I guess my motivation was that I could not see a way to loop through the text in a graph and apply some function to it. It might be easier to directly apply these functions to the text before labelling, rather than changing the labels after they are written, but I hope that this will be possible by using the accessor syntax as you suggest. A more general version of this issue would be a method to pass a list of text-sanitizing-functions to Thank you for linking to |
The plotting routines use For publication figures, I set these manually when reading data: |
Hi @dcherian, Thanks for the good idea! Changing the dataset that you want to plot is probably the easiest option. Here is my implementation of that to go with my original code. def change_ds_for_graph(dsA):
ds = dsA.copy()
for varname, da in ds.data_vars.items():
for attr in da.attrs:
if attr in ['units', 'long_name']:
da.attrs[attr] = proper_units(tex_escape(da.attrs[attr]))
for coord in ds.coords:
for attr in ds.coords[coord].attrs:
if attr in ['units', 'long_name']:
da.coords[coord].attrs[attr] = proper_units(tex_escape(da.coords[coord].attrs[attr]))
return ds |
One problem with
xarray
's default plotting functionality is that the plots look quite mediocre, and so if you want to present your results, then you may have to go in and change all the defaults, and relabel the graphs. This seems like wasted effort.xarray
could supportpdflatex
backend usage bymatplotlib
by sanitizing the labels.It could also change units from
degrees_north
to the more presentable$^{\circ}$N
.An example of doing this is shown below:
The text was updated successfully, but these errors were encountered: