xarray icon indicating copy to clipboard operation
xarray copied to clipboard

Add option to define custom format of units in plots

Open headtr1ck opened this issue 1 year ago • 5 comments

  • [x] Tests added
  • [x] User visible changes (including notable bug fixes) are documented in whats-new.rst
  • [ ] New functions/methods are listed in api.rst

We encountered the issue that we should plot units as (unit) instead of [unit]. This PR enables us to do exactly this, easier to change this at the source ;)

I think setting this as a global option is the correct approach, but feel free to propose alternatives :)

headtr1ck avatar Dec 01 '23 21:12 headtr1ck

yeah I'm not sure we should do this. Is there a more matplotlib-native way through pint perhaps?

dcherian avatar Dec 01 '23 21:12 dcherian

I have simplified this approach, now you define directly the format string instead of the brackets. Much simpler and more flexible.

If you decide to scrap this, also fine by me :)

headtr1ck avatar Dec 02 '23 13:12 headtr1ck

Is the current approach still too specific? I'm fine with closing this.

headtr1ck avatar Jan 24 '24 19:01 headtr1ck

(no particularly strong view from me, I would generally avoid global options as much as possible. I'm not sure whether this is viable on .plot though...)

max-sixty avatar Jan 24 '24 19:01 max-sixty

I'm also inclined to avoid more global options. Our general suggestion in this case is to simply fix up the plot after. I also wonder if there's a way to control formatting by passing pint arrays through.

dcherian avatar Feb 02 '24 22:02 dcherian