Skip to content

Commit

Permalink
Updates to latest ggplto2
Browse files Browse the repository at this point in the history
  • Loading branch information
eliocamp committed Jan 24, 2025
1 parent 8121e1c commit 4104e73
Show file tree
Hide file tree
Showing 22 changed files with 134 additions and 120 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Type: Package
Package: metR
Language: en-GB
Title: Tools for Easier Analysis of Meteorological Fields
Version: 0.17.0
Version: 0.17.0.9000
Authors@R:
c(person(given = "Elio",
family = "Campitelli",
Expand All @@ -24,7 +24,7 @@ Imports:
digest,
Formula,
formula.tools,
ggplot2 (>= 3.0.0),
ggplot2 (>= 3.5.0),
grid,
gtable,
memoise,
Expand Down
3 changes: 1 addition & 2 deletions R/geom_contour_tanaka.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ GeomContourTanaka <- ggplot2::ggproto("GeomContourTanaka", ggplot2::GeomPath,
if (!anyDuplicated(data$group)) {
messagef("%s: Each group consists of only one observation.\nDo you need to adjust the group aesthetic?", "geom_path")
}

# must be sorted on group
data <- data[order(data$group), , drop = FALSE]

Expand Down Expand Up @@ -196,7 +195,7 @@ GeomContourTanaka <- ggplot2::ggproto("GeomContourTanaka", ggplot2::GeomPath,
attr <- plyr::ddply(munched, "group", function(df) {
linetype <- unique(df$linetype)
data.frame(
solid = identical(linetype, 1) || identical(linetype, "solid"),
solid = identical(as.integer(linetype), 1L) || identical(linetype, "solid"),
constant = nrow(unique(df[, c("alpha", "colour","size", "linetype")])) == 1
)
})
Expand Down
6 changes: 3 additions & 3 deletions R/label-scales.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ scale_label_colour_continuous <- function(..., aesthetics = c("label_colour"),
#' @export
#' @rdname label_scales
scale_label_alpha_continuous <- function(..., range = c(0.1, 1), aesthetics = c("label_alpha")) {
ggplot2::continuous_scale("label_alpha", "label_alpha", scales::rescale_pal(range),
ggplot2::continuous_scale(aesthetics = "label_alpha", palette = scales::rescale_pal(range),
...)
}

#' @inheritParams ggplot2::scale_size
#' @export
#' @rdname label_scales
scale_label_size_continuous <- function(name = waiver(), breaks = waiver(), labels = waiver(),
scale_label_size_continuous <- function(breaks = waiver(), labels = waiver(),
limits = NULL, range = c(1, 6), transform = "identity",
guide = "legend") {
ggplot2::continuous_scale("label_size", "label_size", scales::area_pal(range), name = name,
ggplot2::continuous_scale(aesthetics = "label_size", palette = scales::area_pal(range),
breaks = breaks, labels = labels, limits = limits, transform = transform)
}
2 changes: 0 additions & 2 deletions R/stat_contour2.r
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ StatContour2 <- ggplot2::ggproto("StatContour2", ggplot2::Stat,
# contours <- contours[, unique(.SD), by = .(group, piece)]
# contours[, start := NULL]
contours <- .order_contour(contours, data.table::setDT(data))


return(contours)
}
)
Expand Down
14 changes: 14 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ fast.unit.c <- grid::unit.c
.cast_shadow <<- memoise::memoise(.cast_shadow)
streamline.f <<- memoise::memoise(streamline.f)
.order_contour <- memoise::memoise(.order_contour)

ggplot2::register_theme_elements(
palette.label_colour.continuous = scales::pal_seq_gradient("#132B43", "#56B1F7"),
element_tree = list(
palette.label_colour.continuous = ggplot2::el_def(c("character", "numeric", "integer", "function"))
)
)

ggplot2::register_theme_elements(
palette.stroke.colour.continuous = scales::pal_seq_gradient("#132B43", "#56B1F7"),
element_tree = list(
palette.stroke.colour.continuous = ggplot2::el_def(c("character", "numeric", "integer", "function"))
)
)
}


9 changes: 3 additions & 6 deletions man/discretised_scale.Rd

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

6 changes: 4 additions & 2 deletions man/geom_arrow.Rd

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

6 changes: 4 additions & 2 deletions man/geom_contour2.Rd

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

6 changes: 4 additions & 2 deletions man/geom_contour_fill.Rd

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

6 changes: 4 additions & 2 deletions man/geom_contour_tanaka.Rd

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

6 changes: 4 additions & 2 deletions man/geom_relief.Rd

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

6 changes: 4 additions & 2 deletions man/geom_streamline.Rd

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

8 changes: 5 additions & 3 deletions man/geom_text_contour.Rd

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

12 changes: 3 additions & 9 deletions man/label_scales.Rd

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

9 changes: 3 additions & 6 deletions man/scale_divergent.Rd

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

4 changes: 3 additions & 1 deletion man/stat_na.Rd

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

4 changes: 3 additions & 1 deletion man/stat_subset.Rd

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

Binary file modified tests/testthat/Rplots.pdf
Binary file not shown.
Loading

0 comments on commit 4104e73

Please sign in to comment.