| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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:
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.
httpgd 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.
| Back | FazBrowse Home | New Git URL |