From 412a1b865aac3f2c3359e52062a972276210e4db Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 16 Jan 2017 22:44:17 -0500 Subject: [PATCH 1/6] Add documentation for switch param --- man-roxygen/ggmatrix-switch-param.R | 1 + 1 file changed, 1 insertion(+) create mode 100644 man-roxygen/ggmatrix-switch-param.R diff --git a/man-roxygen/ggmatrix-switch-param.R b/man-roxygen/ggmatrix-switch-param.R new file mode 100644 index 000000000..0cfe19763 --- /dev/null +++ b/man-roxygen/ggmatrix-switch-param.R @@ -0,0 +1 @@ +#' @param switch switch parameter for facet_grid. See \code{ggplot2::\link[ggplot2]{facet_grid}}. By default, the labels are displayed on the top and right of the plot. If \code{"x"}, the top labels will be displayed to the bottom. If \code{"y"}, the right-hand side labels will be displayed to the left. Can also be set to \code{"both"} From 7ab48f892b744f6b85f319a7aced527de29c7b94 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 16 Jan 2017 22:44:41 -0500 Subject: [PATCH 2/6] Pass along the switch param --- R/ggmatrix_gtable.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/ggmatrix_gtable.R b/R/ggmatrix_gtable.R index 6abcd9d38..79dd37c00 100644 --- a/R/ggmatrix_gtable.R +++ b/R/ggmatrix_gtable.R @@ -54,7 +54,7 @@ ggmatrix_gtable <- function( pm_fake <- ggplot(fake_data, mapping = aes_("x", "y")) + geom_point() + # make the 'fake' strips for x and y titles - facet_grid(Var2 ~ Var1, labeller = ifnull(pm$labeller, "label_value")) + + facet_grid(Var2 ~ Var1, labeller = ifnull(pm$labeller, "label_value"), switch = pm$switch) + # remove both x and y titles labs(x = pm$xlab, y = pm$ylab) From e00505605039128c92bdaab8e850ce475175476c Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 16 Jan 2017 22:45:03 -0500 Subject: [PATCH 3/6] Add switch param to ggmatrix --- R/ggmatrix.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/ggmatrix.R b/R/ggmatrix.R index bb9a867ef..305dd1263 100644 --- a/R/ggmatrix.R +++ b/R/ggmatrix.R @@ -13,6 +13,7 @@ #' @param showStrips boolean to determine if each plot's strips should be displayed. \code{NULL} will default to the top and right side plots only. \code{TRUE} or \code{FALSE} will turn all strips on or off respectively. #' @param showAxisPlotLabels,showXAxisPlotLabels,showYAxisPlotLabels booleans that determine if the plots axis labels are printed on the X (bottom) or Y (left) part of the plot matrix. If \code{showAxisPlotLabels} is set, both \code{showXAxisPlotLabels} and \code{showYAxisPlotLabels} will be set to the given value. #' @template ggmatrix-labeller-param +#' @template ggmatrix-switch-param #' @param xProportions,yProportions Value to change how much area is given for each plot. Either \code{NULL} (default), numeric value matching respective length, or \code{grid::\link[grid]{unit}} object with matching respective length #' @param byrow boolean that determines whether the plots should be ordered by row or by column #' @param data data set using. This is the data to be used in place of 'ggally_data' if the plot is a string to be evaluated at print time @@ -63,6 +64,7 @@ ggmatrix <- function( showXAxisPlotLabels = TRUE, showYAxisPlotLabels = TRUE, labeller = NULL, + switch = NULL, xProportions = NULL, yProportions = NULL, data = NULL, @@ -93,6 +95,7 @@ ggmatrix <- function( showXAxisPlotLabels = showXAxisPlotLabels, showYAxisPlotLabels = showYAxisPlotLabels, labeller = labeller, + switch = switch, xProportions = xProportions, yProportions = yProportions, legend = legend, From ec901f4b5a7d5785909e7b136db38d69ef3f0619 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 16 Jan 2017 22:45:15 -0500 Subject: [PATCH 4/6] Add switch param to ggduo and ggpairs --- R/ggpairs.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/R/ggpairs.R b/R/ggpairs.R index aa2bf36ba..1d10410fc 100644 --- a/R/ggpairs.R +++ b/R/ggpairs.R @@ -243,6 +243,7 @@ stop_if_high_cardinality <- function(data, columns, threshold) { #' @param axisLabels either "show" to display axisLabels or "none" for no axis labels #' @param columnLabelsX,columnLabelsY label names to be displayed. Defaults to names of columns being used. #' @template ggmatrix-labeller-param +#' @template ggmatrix-switch-param #' @param showStrips boolean to determine if each plot's strips should be displayed. \code{NULL} will default to the top and right side plots only. \code{TRUE} or \code{FALSE} will turn all strips on or off respectively. #' @template ggmatrix-legend-param #' @param cardinality_threshold maximum number of levels allowed in a charcter / factor column. Set this value to NULL to not check factor columns. Defaults to 15 @@ -482,6 +483,7 @@ ggduo <- function( columnLabelsX = colnames(data[columnsX]), columnLabelsY = colnames(data[columnsY]), labeller = "label_value", + switch = NULL, xlab = NULL, ylab = NULL, showStrips = NULL, @@ -584,6 +586,7 @@ ggduo <- function( xAxisLabels = columnLabelsX, yAxisLabels = columnLabelsY, labeller = labeller, + switch = switch, showStrips = showStrips, showXAxisPlotLabels = identical(axisLabels, "show"), showYAxisPlotLabels = identical(axisLabels, "show"), @@ -655,6 +658,7 @@ ggduo <- function( #' @param axisLabels either "show" to display axisLabels, "internal" for labels in the diagonal plots, or "none" for no axis labels #' @param columnLabels label names to be displayed. Defaults to names of columns being used. #' @template ggmatrix-labeller-param +#' @template ggmatrix-switch-param #' @param showStrips boolean to determine if each plot's strips should be displayed. \code{NULL} will default to the top and right side plots only. \code{TRUE} or \code{FALSE} will turn all strips on or off respectively. #' @template ggmatrix-legend-param #' @param cardinality_threshold maximum number of levels allowed in a charcter / factor column. Set this value to NULL to not check factor columns. Defaults to 15 @@ -780,6 +784,7 @@ ggpairs <- function( axisLabels = c("show", "internal", "none"), columnLabels = colnames(data[columns]), labeller = "label_value", + switch = NULL, showStrips = NULL, legend = NULL, cardinality_threshold = 15, @@ -877,6 +882,7 @@ ggpairs <- function( xAxisLabels = (if (axisLabels == "internal") NULL else columnLabels), yAxisLabels = (if (axisLabels == "internal") NULL else columnLabels), labeller = labeller, + switch = switch, showStrips = showStrips, showXAxisPlotLabels = identical(axisLabels, "show"), showYAxisPlotLabels = identical(axisLabels, "show"), From 989555819141bbb44221422a56a02c441ab74ae0 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 16 Jan 2017 22:45:38 -0500 Subject: [PATCH 5/6] document --- man/ggduo.Rd | 6 ++++-- man/ggmatrix.Rd | 6 ++++-- man/ggpairs.Rd | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/man/ggduo.Rd b/man/ggduo.Rd index 9c62aa0b1..65329f5f9 100644 --- a/man/ggduo.Rd +++ b/man/ggduo.Rd @@ -10,8 +10,8 @@ ggduo(data, mapping = NULL, columnsX = 1:ncol(data), discrete = "ratio"), axisLabels = c("show", "none"), columnLabelsX = colnames(data[columnsX]), columnLabelsY = colnames(data[columnsY]), labeller = "label_value", - xlab = NULL, ylab = NULL, showStrips = NULL, legend = NULL, - cardinality_threshold = 15, legends = stop("deprecated")) + switch = NULL, xlab = NULL, ylab = NULL, showStrips = NULL, + legend = NULL, cardinality_threshold = 15, legends = stop("deprecated")) } \arguments{ \item{data}{data set using. Can have both numerical and categorical data.} @@ -30,6 +30,8 @@ ggduo(data, mapping = NULL, columnsX = 1:ncol(data), \item{labeller}{labeller for facets. See \code{\link[ggplot2]{labellers}}. Common values are \code{"label_value"} (default) and \code{"label_parsed"}.} +\item{switch}{switch parameter for facet_grid. See \code{ggplot2::\link[ggplot2]{facet_grid}}. By default, the labels are displayed on the top and right of the plot. If \code{"x"}, the top labels will be displayed to the bottom. If \code{"y"}, the right-hand side labels will be displayed to the left. Can also be set to \code{"both"}} + \item{showStrips}{boolean to determine if each plot's strips should be displayed. \code{NULL} will default to the top and right side plots only. \code{TRUE} or \code{FALSE} will turn all strips on or off respectively.} \item{legend}{May be the two objects described below or the default \code{NULL} value. The legend position can be moved by using ggplot2's theme element \code{pm + theme(legend.position = "bottom")} \describe{\item{a numeric vector of length 2}{provides the location of the plot to use the legend for the plot matrix's legend. Such as \code{legend = c(3,5)} which will use the legend from the plot in the third row and fifth column}\item{a single numeric value}{provides the location of a plot according to the display order. Such as \code{legend = 3} in a plot matrix with 2 rows and 5 columns displayed by column will return the plot in position \code{c(1,2)}}\item{a object from \code{\link{grab_legend}()}}{a predetermined plot legend that will be displayed directly}}} diff --git a/man/ggmatrix.Rd b/man/ggmatrix.Rd index ddd8dbfa7..fc12843d0 100644 --- a/man/ggmatrix.Rd +++ b/man/ggmatrix.Rd @@ -8,8 +8,8 @@ ggmatrix(plots, nrow, ncol, xAxisLabels = NULL, yAxisLabels = NULL, title = NULL, xlab = NULL, ylab = NULL, byrow = TRUE, showStrips = NULL, showAxisPlotLabels = TRUE, showXAxisPlotLabels = TRUE, showYAxisPlotLabels = TRUE, labeller = NULL, - xProportions = NULL, yProportions = NULL, data = NULL, gg = NULL, - legend = NULL) + switch = NULL, xProportions = NULL, yProportions = NULL, data = NULL, + gg = NULL, legend = NULL) } \arguments{ \item{plots}{list of plots to be put into matrix} @@ -28,6 +28,8 @@ ggmatrix(plots, nrow, ncol, xAxisLabels = NULL, yAxisLabels = NULL, \item{labeller}{labeller for facets. See \code{\link[ggplot2]{labellers}}. Common values are \code{"label_value"} (default) and \code{"label_parsed"}.} +\item{switch}{switch parameter for facet_grid. See \code{ggplot2::\link[ggplot2]{facet_grid}}. By default, the labels are displayed on the top and right of the plot. If \code{"x"}, the top labels will be displayed to the bottom. If \code{"y"}, the right-hand side labels will be displayed to the left. Can also be set to \code{"both"}} + \item{xProportions, yProportions}{Value to change how much area is given for each plot. Either \code{NULL} (default), numeric value matching respective length, or \code{grid::\link[grid]{unit}} object with matching respective length} \item{data}{data set using. This is the data to be used in place of 'ggally_data' if the plot is a string to be evaluated at print time} diff --git a/man/ggpairs.Rd b/man/ggpairs.Rd index 933f886f1..7006fa2d4 100644 --- a/man/ggpairs.Rd +++ b/man/ggpairs.Rd @@ -11,8 +11,8 @@ ggpairs(data, mapping = NULL, columns = 1:ncol(data), title = NULL, "densityDiag", discrete = "barDiag", na = "naDiag"), params = NULL, ..., xlab = NULL, ylab = NULL, axisLabels = c("show", "internal", "none"), columnLabels = colnames(data[columns]), labeller = "label_value", - showStrips = NULL, legend = NULL, cardinality_threshold = 15, - legends = stop("deprecated")) + switch = NULL, showStrips = NULL, legend = NULL, + cardinality_threshold = 15, legends = stop("deprecated")) } \arguments{ \item{data}{data set using. Can have both numerical and categorical data.} @@ -39,6 +39,8 @@ ggpairs(data, mapping = NULL, columns = 1:ncol(data), title = NULL, \item{labeller}{labeller for facets. See \code{\link[ggplot2]{labellers}}. Common values are \code{"label_value"} (default) and \code{"label_parsed"}.} +\item{switch}{switch parameter for facet_grid. See \code{ggplot2::\link[ggplot2]{facet_grid}}. By default, the labels are displayed on the top and right of the plot. If \code{"x"}, the top labels will be displayed to the bottom. If \code{"y"}, the right-hand side labels will be displayed to the left. Can also be set to \code{"both"}} + \item{showStrips}{boolean to determine if each plot's strips should be displayed. \code{NULL} will default to the top and right side plots only. \code{TRUE} or \code{FALSE} will turn all strips on or off respectively.} \item{legend}{May be the two objects described below or the default \code{NULL} value. The legend position can be moved by using ggplot2's theme element \code{pm + theme(legend.position = "bottom")} \describe{\item{a numeric vector of length 2}{provides the location of the plot to use the legend for the plot matrix's legend. Such as \code{legend = c(3,5)} which will use the legend from the plot in the third row and fifth column}\item{a single numeric value}{provides the location of a plot according to the display order. Such as \code{legend = 3} in a plot matrix with 2 rows and 5 columns displayed by column will return the plot in position \code{c(1,2)}}\item{a object from \code{\link{grab_legend}()}}{a predetermined plot legend that will be displayed directly}}} From a2dfe8ed9003f2db90a7abd4f8d05602e8caa77b Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 17 Jan 2017 17:01:48 -0500 Subject: [PATCH 6/6] add more options for strip locations --- R/ggmatrix_gtable_helpers.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/ggmatrix_gtable_helpers.R b/R/ggmatrix_gtable_helpers.R index fce6e21aa..71036466f 100644 --- a/R/ggmatrix_gtable_helpers.R +++ b/R/ggmatrix_gtable_helpers.R @@ -56,8 +56,8 @@ plot_panel <- function( # ask about strips layout_names <- c("panel") - strip_right_name <- "strip-r" - strip_top_name <- "strip-t" + strip_right_name <- "strip-r|strip-l" + strip_top_name <- "strip-t|strip-b" legend_name <- "guide-box" all_layout_names <- c(layout_names, strip_right_name, strip_top_name, legend_name) @@ -112,7 +112,7 @@ add_left_axis <- function(pmg, pg, show_strips, grob_pos) { al <- layout[str_detect(layout_name, "axis-l"), ] if (show_strips) { - alx <- layout[str_detect(layout_name, "axis-l|strip-t"), ] + alx <- layout[str_detect(layout_name, "axis-l|strip-t|strip-b"), ] } else { alx <- al } @@ -135,7 +135,7 @@ add_bottom_axis <- function(pmg, pg, show_strips, grob_pos) { al <- layout[str_detect(layout_name, "axis-b"), ] if (show_strips) { - alx <- layout[str_detect(layout_name, "axis-b|strip-r"), ] + alx <- layout[str_detect(layout_name, "axis-b|strip-r|strip-l"), ] } else { alx <- al }