Skip to content

Commit

Permalink
linewidth can now be set in geom_line (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
vandenman committed Jun 23, 2023
1 parent d4403cb commit 3d9475c
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 25 deletions.
5 changes: 3 additions & 2 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
^renv\.lock$
^.*\.Rproj$
^\.Rproj\.user$
^\.git$

^.editorconfig
^.github
^\.editorconfig$
^\.github$
^_pkgdown\.yml$
^docs$
^pkgdown$
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Package: jaspGraphs
Type: Package
Title: Custom Graphs for JASP
Version: 0.5.2.17
Version: 0.6.0
Author: Don van den Bergh
Maintainer: JASP-team <info@jasp-stats.nl>
Description: Graph making functions and wrappers for JASP.
License: GPL
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.0
RoxygenNote: 7.2.3
Suggests: testthat
Imports:
ggplot2 (>= 3.0.0),
Expand Down
2 changes: 1 addition & 1 deletion R/JASPgraphsPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ getDecodeplotFun <- function() {
jaspBaseInstalled <- length(find.package("jaspBase", .libPaths(), quiet = TRUE, verbose = FALSE)) != 0L
if (!jaspBaseInstalled)
return(NULL)
if (packageVersion("jaspBase") < "0.16.4")
if (utils::packageVersion("jaspBase") < "0.16.4")
return(get0("decodeplot"))
else # no longer in the global environment
return(get0("decodeplot", envir = asNamespace("jaspBase")))
Expand Down
35 changes: 31 additions & 4 deletions R/customGeoms.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,42 @@ geom_point <- function(mapping = NULL, data = NULL, stat = "identity", position
jaspGeomLine <- ggplot2::ggproto(
`_class` = "jaspGeomLine",
`_inherit` = ggplot2::GeomLine,
default_aes = aes(size = 1.00, colour = "black", linetype = 1, alpha = NA)
default_aes = aes(linewidth = 1.00, colour = "black", linetype = 1, alpha = NA)
)

#' @rdname geom_point
#' @export
geom_line <- function(mapping = NULL, data = NULL, stat = "identity", position = "identity",
..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE) {

layer(data = data, mapping = mapping, stat = stat, geom = jaspGeomLine,
position = position, show.legend = show.legend, inherit.aes = inherit.aes,
params = list(na.rm = na.rm, ...))
# ggplot2 3.4.0 renamed `size` to `linewidth`. Check if `size` was specified.
# If so, rename it to `linewidth` and show a deprecation warning.

if ("size" %in% ...names()) {
lifecycle::deprecate_warn(
"0.6.0",
"jaspGraphs::geom_line(size)",
"jaspGraphs::geom_line(linewidth)",
details = "In ggplot2 version 3.4.0 the argument `size` was renamed to `linewidth`, likewise in jaspGraphs. For now, jaspGraphs automatically assigned `linewidth = size`. Please fix this in your code, as this will become an error in a future version of jaspGraphs."
)

# specifying both `size` and `linewidth` is an error
if ("linewidth" %in% ...names())
stop("`jaspGraphs::geom_line`: Cannot specify both size and linewidth!", domain = NA)

params <- list(na.rm = na.rm, ...)
params[["linewidth"]] <- params[["size"]]
params <- params[setdiff(names(params), "size")]

layer(data = data, mapping = mapping, stat = stat, geom = jaspGeomLine,
position = position, show.legend = show.legend, inherit.aes = inherit.aes,
params = params)

} else {

layer(data = data, mapping = mapping, stat = stat, geom = jaspGeomLine,
position = position, show.legend = show.legend, inherit.aes = inherit.aes,
params = list(na.rm = na.rm, ...))

}
}
2 changes: 1 addition & 1 deletion R/graphOptions.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
axisTickLength = grid::unit(x = .3, units = "cm"),
axisTickWidth = .3,
digits = list(axes = 3L, BF = 3L),
ggVersion = packageVersion("ggplot2"),
ggVersion = utils::packageVersion("ggplot2"),
palette = "colorblind",
debug = TRUE
))
Expand Down
2 changes: 1 addition & 1 deletion man/geom_abline2.Rd

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

14 changes: 8 additions & 6 deletions man/geom_aligned_text.Rd

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

20 changes: 12 additions & 8 deletions man/geom_rangeframe.Rd

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

0 comments on commit 3d9475c

Please sign in to comment.