pydata / xarray

N-D labeled arrays and datasets in Python
https://xarray.dev
Apache License 2.0
3.5k stars 1.04k forks source link

More advanced tutorial on how to manipulate facetgrid #4793

Open chiaral opened 3 years ago

chiaral commented 3 years ago

Is your feature request related to a problem? Please describe. I have explored a bit the object returned by faceting a plot (usually identified like p in the tutorial). It clearly stores tons of stuff that can be manipulated and make the plots more flexible.

I have an example here which I was planning to add somewhere to the tutorial for plotting.

Would this be of interest? or not since it makes use of i.e. matplotlib methods?

This issue is also intended to call for people that might have been playing with obscure attributes/method/whatever stored in p and have come out with some interesting manipulation. xarray faceting is very powerful, imho, and it is a great starting point for more complicated figures.

For example, in my notebook linked above, I add some axes to the side of the facetgrid to add a meridional average, and it used to take me a second to match the location of the added axes to the location of the axes in the faceted plot. But I figured that:

for oa in p.axes.flat:
    print(oa.get_position().bounds)

gets me the position.

I am sure tons of people have come up with similar stuff - so it would be amazing to put it all together in one spot!

Describe the solution you'd like If there is interest, I will open a PR with an example on how to manipulate faceted plots.

dcherian commented 3 years ago

Hi @chiaral I think a smaller version of that would make a great standalone example: https://xarray.pydata.org/en/stable/examples.html . We can then link to there in the plotting narrative documentation.

It would be great if you could contribute an example showing how to make a similar figure with the example air_temperature dataset.

chiaral commented 3 years ago

Great - I will plan on modifying it using the air_temperature dataset. I will work on it next week on.

shoyer commented 3 years ago

I agree, I would love for facetting to be more easily extended! Documenting what already works is clearly the first step :)

As it, I must admit that although I use FaceGrid for exploratory visualization, I usually end up re-creating facets manually for publications.