vscode-R icon indicating copy to clipboard operation
vscode-R copied to clipboard

Draw plots as SVG

Open Tal500 opened this issue 2 years ago • 3 comments

Currently the plot drawing is done only by drawing as PNG. It will be nice if the user could choose to draw the plots as SVG. Pro: It is faster in communication time and with scalable resolution.

Tal500 avatar Aug 03 '23 14:08 Tal500

Please consider the httpgd viewer option. Or one may find it is useful to edit settings in .vscode-R/settings.json

qianchd avatar Sep 07 '23 04:09 qianchd

Please consider the httpgd viewer option. Or one may find it is useful to edit settings in .vscode-R/settings.json

This option is a possibility, but it's not comfortable in my environment to open up a server, especially trough a remote SSH access. The changes needed from this code are very easy. The crucial one is to modify this line: https://github.com/REditorSupport/vscode-R/blob/9c7f4a217b8cfddd87d9f93489bae09b0923bc8b/R/session/vsc.R#L429 To something like:

 do.call(if(is_svg) svg else png, c(list(filename = plot_file), dev_args)) 

And the side ones are: https://github.com/REditorSupport/vscode-R/blob/9c7f4a217b8cfddd87d9f93489bae09b0923bc8b/R/session/vsc.R#L393 to

 plot_file <- file.path(dir_session, paste0("plot.", if(is_svg) "svg" else "png"))

, and add an option for the user "is_svg" somehow.

This just drops the amount of traffic for detailed graphs significantly.

Tal500 avatar Sep 07 '23 11:09 Tal500