简体   繁体   中英

Plotly: How to export only active legend when exporting plotly graph as png?

I have a plotly graph with more than 80 individual traces: 绘制所有痕迹的png导出

Now I want to export a png with only a few active traces like this: 这是我希望它看起来像的屏幕截图

But when I export the image with the plotly camera icon it shows the top of the legend and not the legend of the active traces: 用 plotly 实际导出

My question is, is there a way to tell plotly to export the graph with only the active trace legends visible?

This is pretty interesting. If you use the approch described here , and run

fig.write_image("yourfile.png")

...then you'll get the original fig object with all traces included. Even after subsetting the series through the legend.

But if you use the camera icon on the toolbar, then you'll get the edited version as a .png file.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM