Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ggfacet switch param for strip location #224

Merged
merged 6 commits into from
May 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions R/ggmatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -63,6 +64,7 @@ ggmatrix <- function(
showXAxisPlotLabels = TRUE,
showYAxisPlotLabels = TRUE,
labeller = NULL,
switch = NULL,
xProportions = NULL,
yProportions = NULL,
data = NULL,
Expand Down Expand Up @@ -93,6 +95,7 @@ ggmatrix <- function(
showXAxisPlotLabels = showXAxisPlotLabels,
showYAxisPlotLabels = showYAxisPlotLabels,
labeller = labeller,
switch = switch,
xProportions = xProportions,
yProportions = yProportions,
legend = legend,
Expand Down
2 changes: 1 addition & 1 deletion R/ggmatrix_gtable.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions R/ggmatrix_gtable_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
6 changes: 6 additions & 0 deletions R/ggpairs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -584,6 +586,7 @@ ggduo <- function(
xAxisLabels = columnLabelsX,
yAxisLabels = columnLabelsY,
labeller = labeller,
switch = switch,
showStrips = showStrips,
showXAxisPlotLabels = identical(axisLabels, "show"),
showYAxisPlotLabels = identical(axisLabels, "show"),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions man-roxygen/ggmatrix-switch-param.R
Original file line number Diff line number Diff line change
@@ -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"}
6 changes: 4 additions & 2 deletions man/ggduo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/ggmatrix.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/ggpairs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.