Configure Plotly download plot button with Shiny

I’m trying to configure the download plot button to output an image in ‘svg’ format. I’m working on a shiny app with R. I render the plot using renderPlotly() function after the following occurs:

  • user selects parameter my_TSG from selectizeInput()
  • parameter my_TSG is parsed and passed to server accordingly: TSG_at_server
  • TSG_at_server calls a file path
  • requested data is loaded to server (from pool of all the data available; to reduce log times) (“*_raw”)
  • requested data is transformed
  • plot is created and called to output$volcano_celllines using renderPlotly()

Currently Plotly v.2.11.1 downloads plots .png and would like to make it format = ‘svg’.

I’m aware of config(fig, toImageButtonOptions = list(…) ) but I do not know how to implement that re-configuration of Plotly within my app.

Please note, App is more complicated than this so hope I simplified it to a reprex that is understandable.

Alternatively, I’m looking for a solution to downloading the plot with higher resolution in png.

######### UI side ##################

ui <- fluidPage( 
	sidebarLayout(
		sidebarPanel(
			selectizeInput( 
				inputId = "my_TSG"
				),
		
			# button confirm TSG
			actionButton(
				inputId = "confirmTSG",
				label = "Confirm TSG", 
				class = "btn btn-default btn-xs"
				),

			actionButton(
				inputId = "goButton",
				label = "Run analysis"
				)

		),	# end of sidebarPanel()


		# Show a plot of the generated analysis
		mainPanel(
			tabsetPanel(
				type = "tabs",
				tabPanel(
					title = "Plot",
					plotlyOutput(outputId = "volcano_celllines", height = 625))
					)
			)	# end of tabsetPanel()
		)	# end of mainPanel()
	)	# end of sidebarLayout()
)	# end of fluid page()



######### server side ##################

server <- function(input, output, session) {

	TSG_at_server <- eventReactive( input$confirmTSG, {rownames(TSG.symbols[match(input$my_TSG, TSG.symbols$'Tumour Supressor Gene')]} )


	######### load required data for plotting #######################
	SL_data_celllines_raw <- {

		reactive({req(input$my_TSG)})	

		file_SL <- reactive({	
		file.path(data.dir, paste0(TSG_at_server(), "/", TSG_at_server(), "_SL.txt.gz"))
		})
			
		reactive({ read.table(gzfile(file_SL()), header = TRUE, sep = "\t", stringsAsFactors = FALSE) })

		}


	SL_data_celllines <- {
		reactive({ cbind(SL_data_celllines_raw(), "gene_symbol" = SL_data_celllines_raw()$label) })
		}


	########## create plot ######################
	plt.SL.tab1 <- eventReactive(input$goButton, {

		ggplot(
			data = SL_data_celllines(),
			aes(x = Effect, y = Pval)
			) +
		geom_point(
			alpha = 0.3
			)

		})


	output$volcano_celllines <- renderPlotly({ plt.SL.tab1() })

}	# end of server function

########## Run the application ##################
shinyApp(
ui = ui,
server = server
)