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

Viewed 206

For the visualization part, I use ggplotly and next knit my markdown file into HTML. Next, when I want to download a static image from plotly output, the quality of the PNG file is very low. So, I wonder if there is a way to increase the quality of downloadable static images in plotly?

enter image description here

1 Answers

You can modify the mode bar when you create a Plotly object. (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
    )
  )
Related