I am trying to improve the quality (resolution) of a plotly plot when using panel.interactive (both in Jupyter and when saved as a file). I am able to improve the quality when using plotly directly with a ‘config’ given to the “show” function as below only for saved file:
config = {
'toImageButtonOptions': {
'format': 'svg', # one of png, svg, jpeg, webp
'scale': 1.0 # Multiply title/legend/axis/canvas sizes by this factor
}
}
fig.show(config=config)
However, I am unable to reproduce this solution when using panel.interactive in the example below:
pn.extension('plotly')
def get_plot_pillars(x_last_data):
df = pd.DataFrame(np.random.randint(0,100,size=(100, 1)), columns=list('A'))
df = df.iloc[-x_last_data:]
df = df.reset_index()
df = pd.melt(df, id_vars=['index'], value_vars=['A'])
fig = px.line(df, x = 'index', y = 'value', template = "plotly_white")
fig.update_layout(legend_title="")
fig.update_layout(paper_bgcolor='rgba(0,0,0,0)',
plot_bgcolor='rgba(0,0,0,0)')
return fig
interact_compo_pnl = pn.interact(get_plot_pillars,
x_last_data = pn.widgets.IntSlider(name='x last data', start=1, end=50, step=1, value=1))
pn.Row(
pn.Column(interact_compo_pnl[0][0]),
interact_compo_pnl[1]
)