Skip to content

Commit

Permalink
include a parameter to control the base size. Related to #6
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpelu committed Sep 8, 2023
1 parent 03d2974 commit d1568b4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions R/ternaryPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
#' @param xvar The name of the variable to be plotted in the x-axis of the ternary plot.
#' @param yvar The name of the variable to be plotted in the y-axis of the ternary plot.
#' @param zvar The name of the variable to be plotted in the z-axis of the ternary plot.
#' @param bsize The base font size for the plot.
#'
#' @return A ggtern plot object displaying the ternary plot.
#'
#' @details This function creates a ternary plot, where data points are represented
#' by points in a triangular coordinate system. The `xvar`, `yvar`, and `zvar`
#' arguments allow you to specify which variables from the `data` argument should
#' be used for each axis. The function also capitalizes the first letter of each
#' variable name for use in the axis labels.
#' variable name for use in the axis labels. You can adjust the base font size
#' (`bsize`) for the plot to control the text size.
#'
#'
#'
#' @seealso \code{\link{ggtern}} for more information on creating ternary plots using ggtern.
#'
Expand All @@ -35,7 +39,7 @@
#' @import ggtern
#' @importFrom stringr str_to_title
#'
ternaryPlot <- function(data, xvar, yvar, zvar) {
ternaryPlot <- function(data, xvar, yvar, zvar, bsize) {
# Capitalize the first letter of variable names for axis labels
xvar_label <- str_to_title(xvar)
yvar_label <- str_to_title(yvar)
Expand All @@ -52,7 +56,7 @@ ternaryPlot <- function(data, xvar, yvar, zvar) {
) +
xlab("") + ylab("") + zlab("") +
theme_showarrows() +
theme_bvbw()
theme_bvbw(base_size = bsize)

return(plot)
}
Expand Down

0 comments on commit d1568b4

Please sign in to comment.