Hi,
I’m trying to save figure after some interaction like zooming and panning.
The problem is that fig.write_image("myimage.png")
writes image with default view settings.
Is there a way to keep zoom and pan when exporting figure as image?
Hi,
I’m trying to save figure after some interaction like zooming and panning.
The problem is that fig.write_image("myimage.png")
writes image with default view settings.
Is there a way to keep zoom and pan when exporting figure as image?
Hi @kerim ,
You can set the xaxis
range and yaxis
range manually to perform zoom before exporting using write_image
method.
Suppose your normal xaxis range is from 0 to 10 and your yaxis range from 0 to 100.
You can set xaxis and yaxis range between these values manually
...
fig.update_xaxes(dict(range=(2.5,4)))
fig.update_yaxes(dict(range=(50,60)))
fig.write_image("myimage.png")
@farispriadi thank you for the hint.
Seems like a possible workaround.
But is it possible to get current axes ranges? because we don’t know what limits to set after user’s manipulations.
That’s possible with dash, IDK about plotly though. Would have to be done in JS.
@AIMPED thank you for the hint!
Is it possible to integrate that to pure python?
Ahaha sorry, can’t undertand the meaning of the second part of the sentance
I guess the answer is: yes?)
What you want to do is possible with dash. In plotly, just using python, I would not know how to do that. I actually believe you can’t do it in plotly python as the interactivity happens in the browser → JS.
I see now… sad but ok, good to know!