Skip to content

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

@MarcSkovMadsen

Description

@MarcSkovMadsen

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.

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.

...
# 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

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

Look and feel

theme_default.mp4
dark_style.mp4

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions