From b2721a92bbf4675bf28ec1de41f4ca08568a16eb Mon Sep 17 00:00:00 2001 From: Martin Menninger Date: Fri, 17 Jul 2026 12:48:30 -0500 Subject: [PATCH] =?UTF-8?q?PR=206=20=E2=80=94=20Replace=20deprecated=20siz?= =?UTF-8?q?e=20with=20linewidth=20=20(#164)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed to linewidth: theme_cmap.R — geom_hline/geom_vline (the origin lines), all six element_line() calls (gridlines, axis lines, ticks), the base line element, and the element_rect() border in theme_cmap_base(). default_aes.R — the GeomLine default only. geom_recessions.R / geom_pandemics.R — the GeomRecessions/GeomPandemics default_aes (size = 0.5 → linewidth = 0.5) and their draw code (lwd = coords$size → coords$linewidth), kept internally consistent. Left as size (correctly): all element_text() font sizes, the text-geom defaults (3.88, fsize/.pt), and the point-geom sizes (GeomPointLast, and the coords$size in the point-drawing code). DESCRIPTION: bumped ggplot2 to >= 3.4.0 in Depends — linewidth was introduced there, so this is now the real floor. Each replacement ran with an exact occurrence-count assertion, so nothing over-matched, and all four R files are brace-balanced and untruncated. Fix typo: theme_cmap_base() read $fgiont instead of $font The `text` element in theme_cmap_base() referenced cmapplot_globals$fgiont$regular$face, which resolved to NULL and dropped the base theme's default font face. Corrected to $font. --- DESCRIPTION | 2 +- R/default_aes.R | 2 +- R/geom_pandemics.R | 4 ++-- R/geom_recessions.R | 4 ++-- R/theme_cmap.R | 22 +++++++++++----------- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a7eaf152..2101944a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,7 +36,7 @@ Encoding: UTF-8 LazyData: true Depends: R (>= 3.5.0), - ggplot2 + ggplot2 (>= 3.4.0) Imports: dplyr, generics, diff --git a/R/default_aes.R b/R/default_aes.R index ada2ebb3..2b3ba83a 100644 --- a/R/default_aes.R +++ b/R/default_aes.R @@ -15,7 +15,7 @@ init_cmap_default_aes <- function() { colour = cmapplot_globals$colors$blackish ), Line = list( - size = gg_lwd_convert(cmapplot_globals$consts$lwd_plotline) + linewidth = gg_lwd_convert(cmapplot_globals$consts$lwd_plotline) ), Text = list( family = cmapplot_globals$font$strong$family, diff --git a/R/geom_pandemics.R b/R/geom_pandemics.R index 95250313..bb54721e 100644 --- a/R/geom_pandemics.R +++ b/R/geom_pandemics.R @@ -262,7 +262,7 @@ GeomPandemics <- ggproto( default_aes = aes( colour = NA, alpha = 0.11, - size = 0.5, + linewidth = 0.5, linetype = 1, na.rm = TRUE, show.legend = FALSE @@ -334,7 +334,7 @@ GeomPandemics <- ggproto( gp = gpar( col = coords$colour, fill = alpha(coords$fill, coords$alpha), - lwd = coords$size * .pt, + lwd = coords$linewidth * .pt, lty = coords$linetype, linejoin = linejoin, # `lineend` is a workaround for Windows and intentionally kept unexposed diff --git a/R/geom_recessions.R b/R/geom_recessions.R index f618b38e..664b708d 100644 --- a/R/geom_recessions.R +++ b/R/geom_recessions.R @@ -289,7 +289,7 @@ NULL #' @export GeomRecessions <- ggproto( "GeomRecessions", Geom, - default_aes = aes(colour = NA, alpha = 0.11, size = 0.5, linetype = 1, na.rm = TRUE), + default_aes = aes(colour = NA, alpha = 0.11, linewidth = 0.5, linetype = 1, na.rm = TRUE), required_aes = c("xformat", "ymin", "ymax", "show_ongoing", "recess_table" ,"fill"), @@ -344,7 +344,7 @@ GeomRecessions <- ggproto( gp = gpar( col = coords$colour, fill = alpha(coords$fill, coords$alpha), - lwd = coords$size * .pt, + lwd = coords$linewidth * .pt, lty = coords$linetype, linejoin = linejoin, # `lineend` is a workaround for Windows and intentionally kept unexposed diff --git a/R/theme_cmap.R b/R/theme_cmap.R index e2c95b3f..8ab66e45 100644 --- a/R/theme_cmap.R +++ b/R/theme_cmap.R @@ -156,7 +156,7 @@ theme_cmap <- function( if(!is.null(hline)){ add_to_obj(ggplot2::geom_hline( yintercept = hline, - size = gg_lwd_convert(consts$lwd_strongline), + linewidth = gg_lwd_convert(consts$lwd_strongline), color = cmapplot_globals$colors$blackish)) } @@ -164,7 +164,7 @@ theme_cmap <- function( if(!is.null(vline)){ add_to_obj(ggplot2::geom_vline( xintercept = vline, - size = gg_lwd_convert(consts$lwd_strongline), + linewidth = gg_lwd_convert(consts$lwd_strongline), color = cmapplot_globals$colors$blackish)) } @@ -184,35 +184,35 @@ theme_cmap <- function( # horizontal gridlines, if specified if (grepl("h", gridlines)) { attr[["panel.grid.major.y"]] <- ggplot2::element_line( - size = gg_lwd_convert(consts$lwd_gridline), + linewidth = gg_lwd_convert(consts$lwd_gridline), color = cmapplot_globals$colors$blackish) } # vertical gridlines, if specified if (grepl("v", gridlines)) { attr[["panel.grid.major.x"]] <- ggplot2::element_line( - size = gg_lwd_convert(consts$lwd_gridline), + linewidth = gg_lwd_convert(consts$lwd_gridline), color = cmapplot_globals$colors$blackish) } # x axis line, if specified if (grepl("x", axislines)) { attr[["axis.line.x"]] <- ggplot2::element_line( - size = gg_lwd_convert(consts$lwd_gridline), + linewidth = gg_lwd_convert(consts$lwd_gridline), color = cmapplot_globals$colors$blackish) } # y axis line, if specified if (grepl("y", axislines)) { attr[["axis.line.y"]] <- ggplot2::element_line( - size = gg_lwd_convert(consts$lwd_gridline), + linewidth = gg_lwd_convert(consts$lwd_gridline), color = cmapplot_globals$colors$blackish) } # x axis ticks, if specified if (grepl("x", axisticks)) { attr[["axis.ticks.x"]] <- ggplot2::element_line( - size = gg_lwd_convert(consts$lwd_gridline), + linewidth = gg_lwd_convert(consts$lwd_gridline), color = cmapplot_globals$colors$blackish) attr[["axis.ticks.length.x"]] <- unit(consts$length_ticks,"bigpts") @@ -221,7 +221,7 @@ theme_cmap <- function( # y axis ticks, if specified if (grepl("y", axisticks)) { attr[["axis.ticks.y"]] <- ggplot2::element_line( - size = gg_lwd_convert(consts$lwd_gridline), + linewidth = gg_lwd_convert(consts$lwd_gridline), color = cmapplot_globals$colors$blackish) attr[["axis.ticks.length.y"]] <- unit(consts$length_ticks,"bigpts") @@ -262,18 +262,18 @@ theme_cmap_base <- function(consts = cmapplot_globals$consts, # building blocks line = element_line( colour = cmapplot_globals$colors$blackish, - size = gg_lwd_convert(consts$lwd_gridline), + linewidth = gg_lwd_convert(consts$lwd_gridline), linetype = 1, lineend = "butt", inherit.blank = TRUE), rect = element_rect( fill = NA, colour = ifelse(debug, "blue", NA), - size = 0.5, linetype = 1, + linewidth = 0.5, linetype = 1, inherit.blank = TRUE), text = element_text( family = cmapplot_globals$font$regular$family, - face = cmapplot_globals$fgiont$regular$face, + face = cmapplot_globals$font$regular$face, size = cmapplot_globals$fsize$M, color = cmapplot_globals$colors$blackish, lineheight = 0.9, hjust = 0.5, vjust = 0.5, angle = 0,