Skip to content

Commit d9d9e0b

Browse files
committed
Add info about printing ggplot objects
1 parent 1da7b83 commit d9d9e0b

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

R/bootstrap.R

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -872,10 +872,16 @@ imageOutput <- function(outputId, width = "100%", height="400px",
872872
#' \code{brush}.
873873
#'
874874
#' For \code{plotOutput}, the coordinates will be sent scaled to the data
875-
#' space, if possible. (At the moment, plots generated by base graphics
876-
#' support this scaling, although plots generated by grid or ggplot2 do not.)
877-
#' If scaling is not possible, the raw pixel coordinates will be sent. For
878-
#' \code{imageOutput}, the coordinates will be sent in raw pixel coordinates.
875+
#' space, if possible. (At the moment, plots generated by base graphics and
876+
#' ggplot2 support this scaling, although plots generated by lattice and
877+
#' others do not.) If scaling is not possible, the raw pixel coordinates will
878+
#' be sent. For \code{imageOutput}, the coordinates will be sent in raw pixel
879+
#' coordinates.
880+
#'
881+
#' With ggplot2 graphics, the code in \code{renderPlot} should return a ggplot
882+
#' object; if instead the code prints the ggplot2 object with something like
883+
#' \code{print(p)}, then the coordinates for interactive graphics will not be
884+
#' properly scaled to the data space.
879885
#'
880886
#' @param outputId output variable to read the plot/image from.
881887
#' @param width,height Image width/height. Must be a valid CSS unit (like
@@ -889,8 +895,8 @@ imageOutput <- function(outputId, width = "100%", height="400px",
889895
#' created by the \code{\link{clickOpts}} function. If you use a value like
890896
#' \code{"plot_click"} (or equivalently, \code{clickOpts(id="plot_click")}),
891897
#' the plot will send coordinates to the server whenever it is clicked, and
892-
#' the value will be accessible via \code{input$plot_click}. The value will
893-
#' be a named list with \code{x} and \code{y} elements indicating the mouse
898+
#' the value will be accessible via \code{input$plot_click}. The value will be
899+
#' a named list with \code{x} and \code{y} elements indicating the mouse
894900
#' position.
895901
#' @param dblclick This is just like the \code{click} argument, but for
896902
#' double-click events.

man/plotOutput.Rd

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ because of how height is computed with HTML/CSS.}
3030
created by the \code{\link{clickOpts}} function. If you use a value like
3131
\code{"plot_click"} (or equivalently, \code{clickOpts(id="plot_click")}),
3232
the plot will send coordinates to the server whenever it is clicked, and
33-
the value will be accessible via \code{input$plot_click}. The value will
34-
be a named list with \code{x} and \code{y} elements indicating the mouse
33+
the value will be accessible via \code{input$plot_click}. The value will be
34+
a named list with \code{x} and \code{y} elements indicating the mouse
3535
position.}
3636

3737
\item{dblclick}{This is just like the \code{click} argument, but for
@@ -97,10 +97,16 @@ The arguments \code{clickId} and \code{hoverId} only work for R base
9797
\code{brush}.
9898

9999
For \code{plotOutput}, the coordinates will be sent scaled to the data
100-
space, if possible. (At the moment, plots generated by base graphics
101-
support this scaling, although plots generated by grid or ggplot2 do not.)
102-
If scaling is not possible, the raw pixel coordinates will be sent. For
103-
\code{imageOutput}, the coordinates will be sent in raw pixel coordinates.
100+
space, if possible. (At the moment, plots generated by base graphics and
101+
ggplot2 support this scaling, although plots generated by lattice and
102+
others do not.) If scaling is not possible, the raw pixel coordinates will
103+
be sent. For \code{imageOutput}, the coordinates will be sent in raw pixel
104+
coordinates.
105+
106+
With ggplot2 graphics, the code in \code{renderPlot} should return a ggplot
107+
object; if instead the code prints the ggplot2 object with something like
108+
\code{print(p)}, then the coordinates for interactive graphics will not be
109+
properly scaled to the data space.
104110
}
105111
\examples{
106112
# Only run these examples in interactive R sessions

0 commit comments

Comments
 (0)