holoviz / holoviz/hvplot

Cannot easily change the default look and feel. It seem to require themes, css and hooks.

Open
#841 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.4k
Forks
124
Avg merge
1d 18h
Merged PRs (30d)
1

Description

I was asked to raise a specific issue.

Basically I would like hvPlot (and holoviews) to provide users with an easy option to select the default look and feel to something that fits their use case and organisation.

```python
hvplot.set_bokeh_style(name="fast-default", accent="purple", font="Helvetica", auto_hide=True)
```

Providing this (for the bokeh backend) includes

- Setting a theme
- Changing some of the css
- applying some changes to the bokeh `plot`.
- `active_tools`
- `toolbar.autohide`
- `toolbar_location`
- double click to reset zoom

I dream of providing this for all backends, but lets start with the bokeh backend.

## Question/ Request

I need some functionality or hints to get

- css
- bokeh `plot` methods

applied across all plot types (for the bokeh backend).

## Example

Basically I need to get the code working for all plots in hvPlot (and holoviews) without Panel and other hacks.

```python
...
# Style
style = DEFAULT_STYLE # or DARK_STYLE

hv.extension("bokeh")
hv.renderer("bokeh").theme = style.bokeh_theme

# adding cmap=style.cmap does not seem to set the cmap on the actual plot
opts.defaults(opts.Bivariate(active_tools=style.active_tools, hooks=style.hooks))
# I don't know how to apply css if not with Panel
pn.config.raw_css.append(style.css)

plot = df.hvplot.bivariate("accel", "mpg", cut=False, cmap=style.cmap, responsive=True)

# Show the plot: `plot` should also look and feel nice in Jupyter without having to import and use Panel.
pn.extension()
pn.panel(plot, sizing_mode="stretch_both").servable()
```

The `hook` function looks like

```python
def hook(self, plot, element):
plot = plot.handles["plot"]
plot.toolbar.autohide = True
plot.js_on_event(DoubleTap, CustomJS(args=dict(p=plot), code="p.reset.emit()"))
plot.toolbar_location="above"
```

The full code is attached

[script.txt](https://github.com/holoviz/hvplot/files/9396729/script.txt)

## Look and feel

https://user-images.githubusercontent.com/42288570/185993868-e655cb3b-f472-4d4c-a9d2-707cc73635d1.mp4

https://user-images.githubusercontent.com/42288570/185993891-5bd06bdb-99fe-4f75-aab0-f473c3eed9cb.mp4

I think there is potential for improvement. But this is already a huge UX improvement.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.