简体   繁体   English

如何从高质量的绘图中将绘图导出为静态图像?

[英]How to export a plot as static Image from plotly with high quality?

For the visualization part, I use ggplotly and next knit my markdown file into HTML.对于可视化部分,我使用 ggplotly,然后将我的 markdown 文件编入 HTML。 Next, when I want to download a static image from plotly output, the quality of the PNG file is very low.接下来,当我想从 plotly 输出中下载静态图像时,PNG 文件的质量非常低。 So, I wonder if there is a way to increase the quality of downloadable static images in plotly?所以,我想知道是否有办法提高可下载静态图像的质量?

在此处输入图像描述

You can modify the mode bar when you create a Plotly object.您可以在创建 Plotly 对象时修改模式栏。 (You can add the change later, as well.) You can see more options regarding the modebar here . (您也可以稍后添加更改。)您可以在此处查看有关模式栏的更多选项。

For example:例如:

library(plotly)
data(gapminder, package = "gapminder")

plot_ly(data = gapminder, x = ~continent, y = ~lifeExp, 
        type = "bar") %>% 
  config(
    toImageButtonOptions = list(
      format = "svg",
      filename = "myplot",
      width = 600,
      height = 700
    )
  )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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