after I set figure (fig = go.Figure) then I dumps python array by this code:
for i in range(len(dataTraceAvg)):
exec("graphJSONAvg.append(dataTraceAvg[{}])".format(i))
graphJSONAvg = json.dumps(graphJSONAvg, cls=plotly.utils.PlotlyJSONEncoder)
In addition, 3.4.0 is going to automatically support responsive resizing when the figure width/height aren’t explicitly specified across all options in plotly.offline.iplot and plotly.offline.plot. See https://github.com/plotly/plotly.py/pull/1234
I am indeed able to make the plot responsive by not specifying neither width nor height in the plotly.graphobjs.Layout object. However, that has the downside of the exported PNG (when clicking on the camera icon on the top right corner of the plot) be too small (when one specifies width and height, the PNG would use such dimensions).
Is there a way to specify width and height and also explicitly request the plot to be responsive?
So far I have tried the suggested config, i.e.
But the resulting plot is not responsive. Am I missing something?
As a workaround I could specify the dimensions for the export function (camera icon), but I haven’t found how to do that. Any help is highly appreciated.
You can use the toImageButtonOptions config parameter to override the save image button’s options. Here’s an example of configuring the figure so that the save image button saves an image with dimensions 1000x400, in svg format, named bar_chart.svg.