Skip to content
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

Add support for opts in explorer #1159

Closed
wants to merge 81 commits into from
Closed

Add support for opts in explorer #1159

wants to merge 81 commits into from

Conversation

ahuang11
Copy link
Collaborator

@ahuang11 ahuang11 commented Oct 1, 2023

As title says, allows using opts; very crude at the moment simply using dict, but it's still useful as an escape hatch.

image

hoxbro and others added 30 commits July 30, 2022 17:40
* WIP overlaying rasterized

* Clean up

* Add rasterize to check for categorical

* Add test

* Add version check

* Update hvplot/converter.py

Co-authored-by: Simon Høxbro Hansen <simon.hansen@me.com>

---------

Co-authored-by: Simon Høxbro Hansen <simon.hansen@me.com>
* Add version check for test

* commit
…explorer (#1146)

* call param.objects() after super().__init__

* add tests

* update the docs

* update error message
* Add autorange option

* Add small documentation about autorange

---------

Co-authored-by: Simon Høxbro Hansen <simon.hansen@me.com>
@ahuang11 ahuang11 added this to the 0.9.0 milestone Oct 1, 2023
@maximlt
Copy link
Member

maximlt commented Oct 3, 2023

I'm not sure to be convinced by this functionality, it seems to only cater to advanced users while it is likely a lot of explorer users are beginner hvPlot users (since it's a good way to access hvPlot's plotting API without having to learn dozens of parameters). I can easily imagine there will be a lot of users clicking on this generic Opts tab and being puzzled by what they see.

If it's a feature that you believe would have unblocked you while working with the explorer, let's see how it could be adapted so that it's obvious it's for advanced usage. For instance, it's not uncommon for GUIs have advanced options that are made visible only after ticking a checkbox. Some text around the options widget would also help understand what kind of input you can provide, with an example.

@ahuang11
Copy link
Collaborator Author

ahuang11 commented Oct 4, 2023

I don't view the explorer as just for beginners. I imagine it's for both beginners and advanced users, with advanced users eventually using it to quickly take a look at their files as others have described here (once CLI is designed and released) . One of the things users need to quickly take a look is adjusting the colorbar like this.

I agree that additional text can be added to help the user out.

Copy link
Member

@maximlt maximlt left a comment

Choose a reason for hiding this comment

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

For this PR to be merged and released in hvPlot 0.9.0, in addition to my inline comments I'd add that:

  • I'd suggest renaming the tab to Advanced and for this tab to be the last one.
  • I'd suggest adding text above the options input to indicate how to use it, what data it accepts (an example could help).

I've tried to run the explorer but the tabs don't show. Ah I realized just know this PR is not targeting main but another PR, something is broken.

image

hvplot/ui.py Show resolved Hide resolved
hvplot/tests/testui.py Show resolved Hide resolved
df = self._data
if len(df) > MAX_ROWS and not (self.kind in KINDS["stats"] or kwargs.get('rasterize') or kwargs.get('datashade')):
df = df.sample(n=MAX_ROWS)
self._layout.loading = True
try:
self._hvplot = _hvPlot(df)(
kind=self.kind, x=self.x, y=y, by=self.by, groupby=self.groupby, **kwargs
)
).opts(**opts_kwargs)
Copy link
Member

Choose a reason for hiding this comment

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

Why not the options to the converter directly? hvPlot has some special options handling given the backend configuration https://hvplot.holoviz.org/user_guide/Plotting_Extensions.html#plot-styling-options

Copy link
Collaborator Author

@ahuang11 ahuang11 Oct 9, 2023

Choose a reason for hiding this comment

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

I wasn't aware that was available, but from my experience, it's less robust, and not all opts are available.

@ahuang11
Copy link
Collaborator Author

ahuang11 commented Oct 9, 2023

To address the following:

I'd suggest renaming the tab to Advanced and for this tab to be the last one.
I'd suggest adding text above the options input to indicate how to use it, what data it accepts (an example could help).

Renamed to advanced and add a doc tooltip which could be copied / pasted. I didn't like how adding text above looked.

image

I've tried to run the explorer but the tabs don't show. Ah I realized just know this PR is not targeting main but another PR, something is broken.

In regards to that, during a merge conflict, I confused self._tabs with pn.Tabs(plot, code) and dropped self._tabs. I renamed self._tabs -> self._control_tabs for clarity.

hvplot/ui.py Outdated Show resolved Hide resolved
@maximlt
Copy link
Member

maximlt commented Oct 10, 2023

Thanks for renaming the tab, I find that much clearer! The tooltip is also very useful.

I need to think more about using .opts(). This is hvPlot and I consider the explorer to be an easy way to learn how to use hvPlot's API, I'm not sure about steering users towards .opts(), specially since hvPlot has some support for passing down options to HoloViews. I've observed with you that it doesn't always work as you'd expect, e.g. color_levels isn't supported, I need to check again how the options (plot, style, norm) are handled.

hvplot/ui.py Outdated Show resolved Hide resolved
@ahuang11
Copy link
Collaborator Author

ahuang11 commented Oct 10, 2023

To me, opts is essential to get the final plot desired. Here's another example that I don't think hvplot alone can do:

import hvplot.xarray
import xarray as xr

df = xr.tutorial.open_dataset("air_temperature")
df.hvplot("lon", "lat").opts(colorbar_opts={"title": "Air Temperature", "width": 10, "bar_line_alpha": 0})
image

learn how to use hvPlot's API

Opts can also be a convenient way for users to understand the connection between hvplot + holoviews.

Base automatically changed from explorer_code to main October 12, 2023 16:17
@maximlt maximlt closed this Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants