Skip to content

Commit

Permalink
Option to change legend size #54
Browse files Browse the repository at this point in the history
  • Loading branch information
adayim committed Dec 9, 2023
1 parent c885d30 commit 05df41d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion R/legend_grob.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ legend_grob <- function(name = "",
y = 0.5,
gp = gpar(fontsize = gp$fontsize,
fontfamily = gp$fontfamily,
cex = gp$cex,
fontface = 'bold',
fill = 'black'))

Expand All @@ -55,7 +56,7 @@ legend_grob <- function(name = "",
# LegendGrob
leg_grob <- legendGrob(label, pch = pch, ncol = ncol,
do.lines = TRUE, byrow = by_row,
hgap = hgap, vgap = vgap,
hgap = hgap*gp$cex, vgap = vgap*gp$cex,
gp = gp)

# Change legendGrob point color
Expand Down
5 changes: 4 additions & 1 deletion R/theme.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#' @param legend_value Legend labels (expressions). A vector should be provided
#' for the grouped forest plot. A "Group 1" etc will be created if not a vector
#' for a grouped forest plot.
#' @param legend_cex Multiplier applied to legend.
#' @param xaxis_lwd Line width for x-axis.
#' @param xaxis_cex Multiplier applied to font size for x-axis.
#' @param refline_lwd Line width for reference line.
Expand Down Expand Up @@ -104,6 +105,7 @@ forest_theme <- function(base_size = 12,
legend_name = "Group",
legend_position = "right",
legend_value = "",
legend_cex = 1,
# X-axis
xaxis_lwd = 0.6,
xaxis_cex = 1,
Expand Down Expand Up @@ -235,7 +237,8 @@ forest_theme <- function(base_size = 12,

# Legend
legend_gp <- list(gp = gpar(fontsize = base_size,
fontfamily = base_family),
fontfamily = base_family,
cex = legend_cex),
name = legend_name,
position = legend_position,
label = legend_value)
Expand Down

0 comments on commit 05df41d

Please sign in to comment.