The plots saved with the ‘download plot as png’/‘snapshot’ button are usually exported with really poor resolution and seem to scale with the viewport.
I’m referring to the button you see in the image, NOT to the static export option.
Is there any way to control the resolution or the size of the PNGs created with this option?
@guidocioni ,
As far as I know, that is not possible using python.
referring by this link
opened 10:03PM - 22 Jan 20 UTC
feature
More explanation needs to be added to https://plot.ly/python/configuration-optio… ns/#remove-modebar-buttons to show:
- how to add buttons to modebar
- buttons' name:
2D: "zoom2d", "pan2d", "select2d", "lasso2d", "zoomIn2d", "zoomOut2d", "autoScale2d", "resetScale2d",
Cartesian: "hoverClosestCartesian", "hoverCompareCartesian",
3D: "zoom3d", "pan3d", "resetCameraDefault3d", "resetCameraLastSave3d", "hoverClosest3d", "orbitRotation", "tableRotation",
GEO: "zoomInGeo", "zoomOutGeo", "resetGeo", "hoverClosestGeo",
Others: "toImage", "sendDataToCloud", "hoverClosestGl2d", "hoverClosestPie", "toggleHover", "resetViews", "toggleSpikelines", “resetViewMapbox"
- how to change their order
The option available is using static export option, but combine with custom download button on Dash app. Also you need to hide the Download plot as a png
from modebar as well.
If you interested, I can provide an example.
Mmm ok I see, however I feel there must be a place where the DPI or the size of the screenshot is hard coded…no?
Hi @guidocioni ,
I found how to resize the downloaded image in Plotly docs.
This is maybe what you need.
this code is an example from link above.
import plotly.express as px
config = {
'toImageButtonOptions': {
'format': 'svg', # one of png, svg, jpeg, webp
'filename': 'custom_image',
'height': 500,
'width': 700,
'scale': 1 # Multiply title/legend/axis/canvas sizes by this factor
}
}
fig = px.bar(x=[1, 2, 3], y=[1, 3, 1])
fig.show(config=config)
hope this help.
Yes, finally! thank you, I don’t know how I didn’t find that page
1 Like