Plot could be displayed in a VS Code editor tab.
When R session watcher is enabled, the default behavior of displaying graphics is to replay the plots to a png
device created over a temporary PNG file. Whenever the plot is updated, the PNG file is revealed in VS Code in an image viewer.
There are known limitations of PNG plot viewer:
par(mfrow =)
is used), then the last page will overwrite the previous pages.grid
package may not work as the plot updates cannot be captured.If the PNG plot viewer is not working properly, one might want to disable it with the following code in ~/.Rprofile
:
options(vsc.plot = FALSE)
Then the plot viewer will fall back to the native plot window. It only takes effect on R session startup.
SVG in httpgd plot viewerhttpgd is an R package to provide a graphics device that asynchronously serves SVG graphics via HTTP and WebSockets. Before using httpgd, install the package via
install.packages("httpgd")
vscode-R supports an SVG plot viewer based on httpgd. Enable r.plot.useHttpgd
in VS Code settings.
Then whenever a plot is created, a Plot viewer tab will be revealed where a number of httpgd features are natively supported.
The httpgd plot viewer supports auto-resizing, light/dark theme mode, plot history, hiding and zoomming.
To show the original httpgd viewer in a webpage in VS Code, put the following code in ~/.Rprofile
:
if (interactive() && Sys.getenv("TERM_PROGRAM") == "vscode") { if (requireNamespace("httpgd", quietly = TRUE)) { options(vsc.plot = FALSE) options(device = function(...) { httpgd::hgd(silent = TRUE) .vsc.browser(httpgd::hgd_url(history = FALSE), viewer = "Beside") }) } }
The httpgd web page supports live update on resizing, history navigation, zooming, save as svg/png/pdf and some other formats.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4