djpr_girafe | R Documentation |
As a Shiny window (html container) is resized, ggplot2 objects (rendered using plotOutput()) change their widths while retaining their height. By default, ggiraph::girafeOutput() objects don't resize in the same way - they maintain their aspect ratio. These functions render these objects in a way that resizes with the browser window.
djpr_girafe(ggobj, height = 5, width = 6, ...)
ggiraph_js(col_widths = c(2, 8, 2))
ggobj |
A ggplot2 object |
height |
height in inches |
width |
width in inches |
... |
Additional options;
passed to |
col_widths |
numeric vector of length 3; elements correspond to Bootstrap widths of 3 columns. Must sum to 12. |
Note that the title, subtitle, and caption are removed from ggobj
using
djprtheme::remove_labs()
.
djpr_girafe()
should be used within renderGirafe({})
, in place of
ggiraph::girafe()
, within the server
component of a Shiny app.
ggiraph_js()
should be called within the Shiny UI, as in
fluidPage(ggiraph_js())
.
A ggiraph::girafe()
object.
https://stackoverflow.com/questions/65267602/can-a-ggiraph-interactive-plot-be-the-size-of-the-window-in-r-shiny and https://stackoverflow.com/questions/45191999/ggiraph-plot-doesnt-resize-to-fit-the-page and https://stackoverflow.com/questions/36995142/get-the-size-of-the-window-in-shiny
## Not run:
library(ggplot2)
p <- ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point() +
labs(title = "Title will be removed in girafe plot")
djpr_girafe(p, 5, 6)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.