How to create a new plot type (with Plotly)?

I’m curious about how I might be able to create a new HoloViews plot type for a custom Plotly figure.

I’m trying to do something a bit unique and would appreciate any feedback or alternative approaches people may have.

The problem: I have many robust plotting routines built on Plotly that I want to incorporate along side some new plotting routines I’m making with HoloViews.

My current solution: Create a “dummy” Plotly element in HoloViews and use the hooks to override and inject my custom Plotly plot (custom_plot_routine() in this example):

import holoviews as hv
import plotly.graph_objects as go

hv.extension('plotly')

def custom_plot_routine(*args, **kwargs):
    """Returns a plotly figure object."""
    # TODO: use element.dataset to pass the real data along to plotly
    fig = go.Figure(
        data=[go.Scatter(x=[0, 60], y=[1, 800], mode="lines")],
    )
    return fig

def hook(plot, element):
    figdata = plot.state
    fig = custom_plot_routine(element)
    # Override/inject the figure data
    figdata.update(fig.to_plotly_json())
    figdata["layout"]["dragmode"] = "pan"

hv.Scatter([0]).opts(hooks=[hook])

This is a total hack, but it kind of works! Though I’d like to take a more robust approach here and see if I could solicit advice on how to create a new HoloViews plot type for my custom plot routines.