xarray-contrib / xarray-tutorial

Xarray Tutorials
https://tutorial.xarray.dev/
Apache License 2.0
166 stars 106 forks source link

Use dynamic=False and groupby multi-dim #268

Open ahuang11 opened 4 weeks ago

ahuang11 commented 4 weeks ago

I think it's more impressive if users can try out the slider.

image
review-notebook-app[bot] commented 4 weeks ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

scottyhq commented 2 weeks ago

Thanks @ahuang11 I agree this would be nice, but if I view the HTML generated by jupyterbook the slider doesn't update the plot. You can access the HTML as a build artifact in the CI https://github.com/xarray-contrib/xarray-tutorial/actions/runs/9473640096?pr=268

maybe related: https://github.com/holoviz/hvplot/issues/1241

The preview of the slider that should advance is here https://xarray-contrib-xarray-tutorial-preview-pr-268.surge.sh/overview/xarray-in-45-min.html#holoviz

github-actions[bot] commented 2 weeks ago

🎊 PR Preview 38e88b58f4599f68ad322b4a2dfda5083d2703c1 has been successfully built and deployed to https://xarray-contrib-xarray-tutorial-preview-pr-268.surge.sh

🕐 Build time: 0.01s

🤖 By surge-preview

ahuang11 commented 1 week ago

You're right; seems like an issue.

To get around that, maybe can demo how powerful hvPlot can be simply by ticking off keywords such as groupby, hover, responsive, etc? Unless that's too many keywords?

image

Not sure which one I like more, explicit x/y and implicit groupby, or vice versa.

import hvplot.xarray

ds.groupby("time.season").mean().hvplot(
    groupby=["season", "lat"],
    hover="vline",
    responsive=True,
    dynamic=False,
    ylim=(240, 310),
    min_height=350,
)
ds.groupby("time.season").mean().hvplot(
    x="lon",
    y="air",
    hover="vline",
    responsive=True,
    dynamic=False,
    ylim=(240, 310),
    min_height=350,
)
scottyhq commented 1 week ago

Those are great suggestions! Whatever your think is best without being too much to take in.

For the existing case, it seems that just removing widget_location='bottom' might fix the interactivity

We also have this separate notebook focused entirely on hvplot https://tutorial.xarray.dev/intermediate/hvplot.html !

ahuang11 commented 1 week ago

I think the current changes is a better example to highlight hvPlot's capabilities, and I'd be happy for this to be merged when you think it's ready.

For the existing case, it seems that just removing widget_location='bottom' might fix the interactivity

Yes. I think it might squish the plot a bit too much, but a line plot is still readable.

We also have this separate notebook focused entirely on hvplot https://tutorial.xarray.dev/intermediate/hvplot.html !

Would you like me to try revising that too? Particularly, I think it can also show other type of plots.

scottyhq commented 1 week ago

I think the current changes is a better example to highlight hvPlot's capabilities, and I'd be happy for this to be merged when you think it's ready.

I really like that the new plot is interactive both on the website and the notebook. It is however a bit complicated. I'd suggest keeping the "Xarray in 45 minutes" example super simple (otherwise when presenting these notebooks in tutorial settings you get lots of questions).

Would you like me to try revising that too? Particularly, I think it can also show other type of plots.

How about your original suggestion of just embedding a couple time slices in the overview notebook and adding this new excellent example of grouping by season and latitude in the 'intermediate' notebook? For this new example and any others you'd like to add please explain what each keyword is doing and link to the relevant upstream docs (here https://hvplot.holoviz.org/user_guide/Customization.html#generic-options ?)