I’m using Python 2.7 on Debian Linux to generate a stacked bar chart with bar totals and a target plot. When I look at it in a browser it looks fine, when I use the “Download plot as a png” button the resulting image is less than half of the bar chart as the captions overlay it (although the bar totals are still displayed).
I think it may be a scaling issue on the download, but I’m not sure how to specify what scale to use. Has anybody come across this before and can offer advice please.
OK, thanks. Would it be possible for you to upgrade to the latest version of plotly (4.3), for example with pip install -U plotly, and see if the problem persists? I’d like to know if the bug is still present in the latest version.
It gives the same result as I was originally getting when downloading as a PNG. I also tried a different browser with all the cookies cleared but that didn’t make any difference (Chrome instead of Firefox)
Hi again, it turns out this is a known issue. When you display the figure, do fig.show(config={toImageButtonOptions: {width: null, height: null}}) in order to force the download-to-png button to follow the figure dimensions (otherwise it’s using fixed dimensions). More details in https://github.com/plotly/plotly.js/pull/3746
Thank you Emmanuelle and RenauldLN, you have solved my problem really quickly.
I’m using Python to generate the chart so I adapted your code as follows:
import plotly.graph_objects as go
import plotly.io as pio
.
.
l_go_bar = []
for i in range(len(l_site_names)):
l_go_bar.append(go.Bar(name=l_site_names[i], x=l_x_axis, y=l_y_axes[i]))
fig = go.Figure(data=l_go_bar)
pio.write_html(fig, config={'toImageButtonOptions': {'width':None, 'height':None}}, file=v_rpt_dir + v_report_file_name)
It all works perfectly now and I have some very happy users.