From 3db5f21d90b27d02ffacd04fdecfc65a4d9e0c24 Mon Sep 17 00:00:00 2001 From: Winston Chang Date: Tue, 7 Aug 2018 14:59:06 -0500 Subject: [PATCH] Update data structure comment --- R/render-plot.R | 184 ++++++++++++++++++++++++++---------------------- 1 file changed, 98 insertions(+), 86 deletions(-) diff --git a/R/render-plot.R b/R/render-plot.R index ec5595b76..adc5f9509 100644 --- a/R/render-plot.R +++ b/R/render-plot.R @@ -284,22 +284,26 @@ custom_print.ggplot <- function(x) { # below. For base graphics: # plot(mtcars$wt, mtcars$mpg) # str(getPrevPlotCoordmap(400, 300)) -# List of 1 -# $ :List of 4 -# ..$ domain :List of 4 -# .. ..$ left : num 1.36 -# .. ..$ right : num 5.58 -# .. ..$ bottom: num 9.46 -# .. ..$ top : num 34.8 -# ..$ range :List of 4 -# .. ..$ left : num 50.4 -# .. ..$ right : num 373 -# .. ..$ bottom: num 199 -# .. ..$ top : num 79.6 -# ..$ log :List of 2 -# .. ..$ x: NULL -# .. ..$ y: NULL -# ..$ mapping: Named list() +# List of 2 +# $ panels:List of 1 +# ..$ :List of 4 +# .. ..$ domain :List of 4 +# .. .. ..$ left : num 1.36 +# .. .. ..$ right : num 5.58 +# .. .. ..$ bottom: num 9.46 +# .. .. ..$ top : num 34.8 +# .. ..$ range :List of 4 +# .. .. ..$ left : num 65.6 +# .. .. ..$ right : num 366 +# .. .. ..$ bottom: num 238 +# .. .. ..$ top : num 48.2 +# .. ..$ log :List of 2 +# .. .. ..$ x: NULL +# .. .. ..$ y: NULL +# .. ..$ mapping: Named list() +# $ dims :List of 2 +# ..$ width : num 400 +# ..$ height: num 300 # # For ggplot2, first you need to define the print.ggplot function from inside # renderPlot, then use it to print the plot: @@ -318,29 +322,33 @@ custom_print.ggplot <- function(x) { # } # # p <- print(ggplot(mtcars, aes(wt, mpg)) + geom_point()) -# str(getGgplotCoordmap(p, 1, 72)) -# List of 1 -# $ :List of 10 -# ..$ panel : int 1 -# ..$ row : int 1 -# ..$ col : int 1 -# ..$ panel_vars: Named list() -# ..$ log :List of 2 -# .. ..$ x: NULL -# .. ..$ y: NULL -# ..$ domain :List of 4 -# .. ..$ left : num 1.32 -# .. ..$ right : num 5.62 -# .. ..$ bottom: num 9.22 -# .. ..$ top : num 35.1 -# ..$ mapping :List of 2 -# .. ..$ x: chr "wt" -# .. ..$ y: chr "mpg" -# ..$ range :List of 4 -# .. ..$ left : num 40.8 -# .. ..$ right : num 446 -# .. ..$ bottom: num 263 -# .. ..$ top : num 14.4 +# str(getGgplotCoordmap(p, 400, 300, 72)) +# List of 2 +# $ panels:List of 1 +# ..$ :List of 8 +# .. ..$ panel : num 1 +# .. ..$ row : num 1 +# .. ..$ col : num 1 +# .. ..$ panel_vars: Named list() +# .. ..$ log :List of 2 +# .. .. ..$ x: NULL +# .. .. ..$ y: NULL +# .. ..$ domain :List of 4 +# .. .. ..$ left : num 1.32 +# .. .. ..$ right : num 5.62 +# .. .. ..$ bottom: num 9.22 +# .. .. ..$ top : num 35.1 +# .. ..$ mapping :List of 2 +# .. .. ..$ x: chr "wt" +# .. .. ..$ y: chr "mpg" +# .. ..$ range :List of 4 +# .. .. ..$ left : num 33.3 +# .. .. ..$ right : num 355 +# .. .. ..$ bottom: num 328 +# .. .. ..$ top : num 5.48 +# $ dims :List of 2 +# ..$ width : num 400 +# ..$ height: num 300 # # With a faceted ggplot2 plot, the outer list contains two objects, each of # which represents one panel. In this example, there is one panelvar, but there @@ -348,54 +356,58 @@ custom_print.ggplot <- function(x) { # mtc <- mtcars # mtc$am <- factor(mtc$am) # p <- print(ggplot(mtc, aes(wt, mpg)) + geom_point() + facet_wrap(~ am)) -# str(getGgplotCoordmap(p, 1, 72)) +# str(getGgplotCoordmap(p, 400, 300, 72)) # List of 2 -# $ :List of 10 -# ..$ panel : int 1 -# ..$ row : int 1 -# ..$ col : int 1 -# ..$ panel_vars:List of 1 -# .. ..$ panelvar1: Factor w/ 2 levels "0","1": 1 -# ..$ log :List of 2 -# .. ..$ x: NULL -# .. ..$ y: NULL -# ..$ domain :List of 4 -# .. ..$ left : num 1.32 -# .. ..$ right : num 5.62 -# .. ..$ bottom: num 9.22 -# .. ..$ top : num 35.1 -# ..$ mapping :List of 3 -# .. ..$ x : chr "wt" -# .. ..$ y : chr "mpg" -# .. ..$ panelvar1: chr "am" -# ..$ range :List of 4 -# .. ..$ left : num 45.6 -# .. ..$ right : num 317 -# .. ..$ bottom: num 251 -# .. ..$ top : num 35.7 -# $ :List of 10 -# ..$ panel : int 2 -# ..$ row : int 1 -# ..$ col : int 2 -# ..$ panel_vars:List of 1 -# .. ..$ panelvar1: Factor w/ 2 levels "0","1": 2 -# ..$ log :List of 2 -# .. ..$ x: NULL -# .. ..$ y: NULL -# ..$ domain :List of 4 -# .. ..$ left : num 1.32 -# .. ..$ right : num 5.62 -# .. ..$ bottom: num 9.22 -# .. ..$ top : num 35.1 -# ..$ mapping :List of 3 -# .. ..$ x : chr "wt" -# .. ..$ y : chr "mpg" -# .. ..$ panelvar1: chr "am" -# ..$ range :List of 4 -# .. ..$ left : num 322 -# .. ..$ right : num 594 -# .. ..$ bottom: num 251 -# .. ..$ top : num 35.7 +# $ panels:List of 2 +# ..$ :List of 8 +# .. ..$ panel : num 1 +# .. ..$ row : int 1 +# .. ..$ col : int 1 +# .. ..$ panel_vars:List of 1 +# .. .. ..$ panelvar1: Factor w/ 2 levels "0","1": 1 +# .. ..$ log :List of 2 +# .. .. ..$ x: NULL +# .. .. ..$ y: NULL +# .. ..$ domain :List of 4 +# .. .. ..$ left : num 1.32 +# .. .. ..$ right : num 5.62 +# .. .. ..$ bottom: num 9.22 +# .. .. ..$ top : num 35.1 +# .. ..$ mapping :List of 3 +# .. .. ..$ x : chr "wt" +# .. .. ..$ y : chr "mpg" +# .. .. ..$ panelvar1: chr "am" +# .. ..$ range :List of 4 +# .. .. ..$ left : num 33.3 +# .. .. ..$ right : num 191 +# .. .. ..$ bottom: num 328 +# .. .. ..$ top : num 23.1 +# ..$ :List of 8 +# .. ..$ panel : num 2 +# .. ..$ row : int 1 +# .. ..$ col : int 2 +# .. ..$ panel_vars:List of 1 +# .. .. ..$ panelvar1: Factor w/ 2 levels "0","1": 2 +# .. ..$ log :List of 2 +# .. .. ..$ x: NULL +# .. .. ..$ y: NULL +# .. ..$ domain :List of 4 +# .. .. ..$ left : num 1.32 +# .. .. ..$ right : num 5.62 +# .. .. ..$ bottom: num 9.22 +# .. .. ..$ top : num 35.1 +# .. ..$ mapping :List of 3 +# .. .. ..$ x : chr "wt" +# .. .. ..$ y : chr "mpg" +# .. .. ..$ panelvar1: chr "am" +# .. ..$ range :List of 4 +# .. .. ..$ left : num 197 +# .. .. ..$ right : num 355 +# .. .. ..$ bottom: num 328 +# .. .. ..$ top : num 23.1 +# $ dims :List of 2 +# ..$ width : num 400 +# ..$ height: num 300 getCoordmap <- function(x, width, height, res) {