how can I change size of a plotly graph rendered in static format.
fig.show(renderer='svg')
The svg format renders the graph in a static image and shrinks the graph too, how do i make it bigger.
how can I change size of a plotly graph rendered in static format.
fig.show(renderer='svg')
The svg format renders the graph in a static image and shrinks the graph too, how do i make it bigger.
Image size can be specified in layout:
import plotly.graph_objects as go
import plotly.io as pio
layout = go.Layout(
autosize=False,
width=900,
height=900
)
fig = go.Figure(data=go.Bar(y=[2, 3, 1]), layout=layout)
# save image if needed
pio.write_image(fig, 'fig1.svg')
fig.show(renderer='svg')
Did you try passing width and height to the fig.show() method:
fig.show(
renderer='svg',
width = 800, # or width = fig.layout.width, if you've set that already
height = 600 # or height = fig.layout.height
)
One would expect Alexandra's answer to help, but it seems that with some versions of JupyterLab/plotly (in my case JupyterLab 3.0.16 with plotly 5 and kaleido 0.2), the static renderers don't automagically pick up the width and height specified in fig.layout.