Skip to content

Conversation

dcherian
Copy link
Contributor

@dcherian dcherian commented Jul 2, 2018

  • Tests added (for all bug fixes or enhancements)
  • Tests passed (for all non-documentation changes)
  • Fully documented, including whats-new.rst for all changes and api.rst for new API (remove if this change should not be visible to users, e.g., if it is an internal clean-up, or if this is part of a larger project that will be documented later)

Added support for errorbar plotting. This works by providing the kwargs xerr and/or yerr to plot() or plot.line(). It will only work for 1D data.

Errorbars for plots that usehue argument require that we loop and plot each line individually. I'm happy to add this is you think it's a good idea.

Example from docs:
air.isel(time=10, lon=10).plot.line(y='lat', xerr=3, yerr=1.5, ecolor='r')

image

@shoyer
Copy link
Member

shoyer commented Jul 3, 2018

Very cool!

Errorbars for plots that usehue argument require that we loop and plot each line individually. I'm happy to add this is you think it's a good idea.

I'm pretty sure that under the covers matplotlib uses a loop when plt.plot results in multiple lines. So this seems pretty reasonable to me.

Copy link
Member

@jhamman jhamman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Just a minor docstring suggestion.

@@ -270,6 +270,7 @@ def line(darray, *args, **kwargs):
Coordinates for x, y axis. Only one of these may be specified.
The other coordinate plots values from the DataArray on which this
plot method is called.
xerr, yerr : Errorbar sizes (optional)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we expand this description?

@dcherian dcherian changed the title DataArray.plot() can now plot errorbars with kwargs xerr, yerr WIP DataArray.plot() can now plot errorbars with kwargs xerr, yerr Sep 19, 2018
@dcherian dcherian closed this Aug 15, 2019
@dcherian dcherian deleted the line-errorbar branch August 15, 2019 15:32
@marccheneau
Copy link

Hi there. I have read this thread with a great interest as I was wondering whether it was possible to plot data from a Dataset with errorbars. Yet it seems that the changes discussed here were not merged in the end. At least I can't find the corresponding piece of code in the latest version of xarray/plot/plot.py.
What is the current status of this feature?

@dcherian dcherian restored the line-errorbar branch April 6, 2020 17:14
@dcherian
Copy link
Contributor Author

dcherian commented Apr 6, 2020

This never went in because I never finished it :)

One bit of weirdness is that the return types are different for plt.plot and plt.errorbar so the return type for xarray.plot will change when xerr or yerr is specified. I don't know if we should care too much.

Feel free to take over

@marccheneau
Copy link

I will have a look at it, starting with your initial commit. Regarding the change of return type, I won't be able to judge whether this can cause trouble or not.

@dcherian dcherian deleted the line-errorbar branch October 18, 2022 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants