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

Complement documentation for atom plots #185

Merged
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
7 changes: 4 additions & 3 deletions R/atom-plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ addScatter <- function(data = NULL,
data <- data.frame(data, check.names = FALSE)
}

dataMapping <- dataMapping %||% XYGDataMapping$new(x = x, y = y, data = data)
dataMapping <- dataMapping %||% XYGDataMapping$new(x = "x", y = "y", data = data)
plotConfiguration <- plotConfiguration %||% PlotConfiguration$new(data = data, metaData = metaData, dataMapping = dataMapping)
# Update plotConfiguration if user defined aesthetics
eval(parseVariableToObject("plotConfiguration$points", c("color", "shape", "linetype", "size"), keepIfNull = TRUE))
Expand Down Expand Up @@ -198,6 +198,7 @@ addScatter <- function(data = NULL,
#' aesthetic properties defined in `plotConfiguration` will apply across all layers.
#' @return A `ggplot` graphical object
#' @examples
#' \dontrun{
#' # Add vertical line at x = 2
#' addLine(x = 2)
#'
Expand All @@ -211,7 +212,7 @@ addScatter <- function(data = NULL,
#'
#' # Add horizontal line at y = 5 to a previous plot
#' p <- addLine(y = 5, plotObject = p)
#'
#'}
#' # Add a custom line
#' time <- seq(0, 30, 0.01)
#' customLineData <- data.frame(x = time, y = cos(time))
Expand Down Expand Up @@ -254,7 +255,7 @@ addLine <- function(data = NULL,
data <- data.frame(data, check.names = FALSE)
}

dataMapping <- dataMapping %||% XYGDataMapping$new(x = x, y = y, data = data)
dataMapping <- dataMapping %||% XYGDataMapping$new(x = "x", y = "y", data = data)
plotConfiguration <- plotConfiguration %||% PlotConfiguration$new(data = data, metaData = metaData, dataMapping = dataMapping)
# Update plotConfiguration if user defined aesthetics
eval(parseVariableToObject("plotConfiguration$lines", c("color", "shape", "linetype", "size"), keepIfNull = TRUE))
Expand Down
4 changes: 2 additions & 2 deletions R/utilities-mapping.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ smartMapping <- function(data) {

# Names of data.frame variables
variableNames <- names(data)
# If one column, set as y
if (ncol(data) == 1) {
# If one column, set as y unless name is "x"
if (ncol(data) == 1 & !(variableNames[1] %in% "x")) {
mapping$y <- variableNames[1]
}
# If 2 columns, set as x, y
Expand Down
3 changes: 2 additions & 1 deletion man/addLine.Rd

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

Loading