Pn.save (svg) workarounds

Hi everyone,

I’m working on a project using Panel and hvPlot with Plotly as the backend. I have created a layout of plots and successfully saved it as a PNG using main_layout.save("example-presentation.png"). However, I would like to save this layout as an SVG instead.

Here’s my code:

import numpy as np
import pandas as pd
import hvplot.pandas
import panel as pn
import holoviews as hv
from holoviews import opts

# Set hvPlot backend to Plotly
hvplot.extension("plotly")

# Define a hook to disable the Plotly toolbar
def disable_toolbar_hook(plot, element):
    if "config" in plot.state:
        plot.state["config"]["displayModeBar"] = False  # Disable the Plotly toolbar

# Generate dummy data
x = np.linspace(0, 10, 100)
data_top = pd.DataFrame({'x': x, 'y': np.sin(x)})
data_bottom_left = pd.DataFrame({'x': x, 'y': np.cos(x)})
data_bottom_right = pd.DataFrame({'x': x, 'y': np.tan(x)})

# Create plots with hooks
top_plot = data_top.hvplot(x='x', y='y', title="Top Plot", responsive=True).opts(
    hooks=[disable_toolbar_hook]
)
bottom_left_plot = data_bottom_left.hvplot(x='x', y='y', title="Bottom Left Plot", responsive=True).opts(
    hooks=[disable_toolbar_hook]
)
bottom_right_plot = data_bottom_right.hvplot(x='x', y='y', title="Bottom Right Plot", responsive=True).opts(
    hooks=[disable_toolbar_hook]
)

# Fixed layout dimensions
main_layout = pn.Column(
    pn.Row(top_plot),  # Top plot
    pn.Row(bottom_left_plot, bottom_right_plot),  # Two bottom plots side by side
    sizing_mode="fixed",  # Fixed layout
    width=int(9 * 96),  # 9 inches in pixels
    height=int(6 * 96),  # 6 inches in pixels
)

# Embed the layout in the notebook
main_layout.embed()

# Save the layout as PNG
main_layout.save("example-presentation.png")

This works well for PNG, but my goal is to save the layout as an SVG. Is there a way to achieve this in Panel or through another compatible method?

Any help or guidance would be greatly appreciated!