Skip to content

Consolidate scale definition of position aesthetics #5640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# ggplot2 (development version)

* All position scales now use the same definition of `x` and `y` aesthetics.
This lets uncommon aesthetics like `xintercept` expand scales as usual.
(#3342, #4966, @teunbrand)
* Bare numeric values provided to Date or Datetime scales get inversely
transformed (cast to Date/POSIXct) with a warning (@teunbrand).
* `stat_bin()` now accepts functions for argument `breaks` (@aijordan, #4561)
* (internal) The plot's layout now has a coord parameter that is used to
prevent setting up identical panel parameters (#5427)
Expand Down
27 changes: 22 additions & 5 deletions R/scale-date.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ scale_x_date <- function(name = waiver(),
sec.axis = waiver()) {

sc <- datetime_scale(
c("x", "xmin", "xmax", "xend"),
ggplot_global$x_aes,
"date",
name = name,
palette = identity,
Expand Down Expand Up @@ -118,7 +118,7 @@ scale_y_date <- function(name = waiver(),
sec.axis = waiver()) {

sc <- datetime_scale(
c("y", "ymin", "ymax", "yend"),
ggplot_global$y_aes,
"date",
name = name,
palette = identity,
Expand Down Expand Up @@ -156,7 +156,7 @@ scale_x_datetime <- function(name = waiver(),
sec.axis = waiver()) {

sc <- datetime_scale(
c("x", "xmin", "xmax", "xend"),
ggplot_global$x_aes,
"time",
name = name,
palette = identity,
Expand Down Expand Up @@ -196,7 +196,7 @@ scale_y_datetime <- function(name = waiver(),
sec.axis = waiver()) {

sc <- datetime_scale(
c("y", "ymin", "ymax", "yend"),
ggplot_global$y_aes,
"time",
name = name,
palette = identity,
Expand Down Expand Up @@ -317,7 +317,7 @@ datetime_scale <- function(aesthetics, transform, trans = deprecated(),

# x/y position aesthetics should use ScaleContinuousDate or
# ScaleContinuousDatetime; others use ScaleContinuous
if (all(aesthetics %in% c("x", "xmin", "xmax", "xend", "y", "ymin", "ymax", "yend"))) {
if (all(aesthetics %in% c(ggplot_global$x_aes, ggplot_global$y_aes))) {
scale_class <- switch(
transform,
date = ScaleContinuousDate,
Expand Down Expand Up @@ -362,6 +362,13 @@ ScaleContinuousDatetime <- ggproto("ScaleContinuousDatetime", ScaleContinuous,
self$timezone <- tz
self$trans <- transform_time(self$timezone)
}
if (is_bare_numeric(x)) {
x <- self$trans$inverse(x)
cli::cli_warn(c(
"A {.cls numeric} value was passed to a {.field Datetime} scale.",
i = "The value was converted to {obj_type_friendly(x)}."
), call = self$call)
}
ggproto_parent(ScaleContinuous, self)$transform(x)
},
map = function(self, x, limits = self$get_limits()) {
Expand Down Expand Up @@ -401,6 +408,16 @@ ScaleContinuousDate <- ggproto("ScaleContinuousDate", ScaleContinuous,
map = function(self, x, limits = self$get_limits()) {
self$oob(x, limits)
},
transform = function(self, x) {
if (is_bare_numeric(x)) {
x <- self$trans$inverse(x)
cli::cli_warn(c(
"A {.cls numeric} value was passed to a {.field Date} scale.",
i = "The value was converted to {obj_type_friendly(x)}."
), call = self$call)
}
ggproto_parent(ScaleContinuous, self)$transform(x)
},
get_breaks = function(self, limits = self$get_limits()) {
breaks <- ggproto_parent(ScaleContinuous, self)$get_breaks(limits)
if (is.null(breaks)) {
Expand Down
4 changes: 2 additions & 2 deletions R/scale-discrete-.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ scale_x_discrete <- function(name = waiver(), ..., palette = seq_len,
expand = waiver(), guide = waiver(),
position = "bottom", sec.axis = waiver()) {
sc <- discrete_scale(
aesthetics = c("x", "xmin", "xmax", "xend"), name = name,
aesthetics = ggplot_global$x_aes, name = name,
palette = palette, ...,
expand = expand, guide = guide, position = position,
super = ScaleDiscretePosition
Expand All @@ -86,7 +86,7 @@ scale_y_discrete <- function(name = waiver(), ..., palette = seq_len,
expand = waiver(), guide = waiver(),
position = "left", sec.axis = waiver()) {
sc <- discrete_scale(
aesthetics = c("y", "ymin", "ymax", "yend"), name = name,
aesthetics = ggplot_global$y_aes, name = name,
palette = palette, ...,
expand = expand, guide = guide, position = position,
super = ScaleDiscretePosition
Expand Down
244 changes: 216 additions & 28 deletions revdep/README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,222 @@
# Revdeps

## Failed to check (17)
## Failed to check (146)

|package |version |error |warning |note |
|:----------------|:-------|:-----|:-------|:----|
|bayesdfa |1.3.3 |1 | | |
|bmgarch |2.0.0 |1 | | |
|ctsem |3.9.1 |1 | | |
|EcoEnsemble |1.0.5 |1 | | |
|geostan |0.5.4 |1 | | |
|grandR |? | | | |
|multilevelcoda |1.2.3 |1 | | |
|multinma |0.6.1 |1 | | |
|rmsb |1.1-0 |1 | | |
|rstanarm |2.32.1 |1 | | |
|Seurat |? | | | |
|streamDAG |? | | | |
|treestats |1.0.5 |1 | | |
|TriDimRegression |1.0.2 |1 | | |
|triptych |0.1.2 |1 | | |
|ubms |1.2.6 |1 | | |
|valse |0.1-0 |1 | | |
|package |version |error |warning |note |
|:----------------------|:----------|:------|:-------|:----|
|abctools |1.1.7 |1 | | |
|AnanseSeurat |? | | | |
|animalEKF |1.2 |1 | | |
|ANOM |0.5 |1 | | |
|APackOfTheClones |? | | | |
|atRisk |0.1.0 |1 | | |
|AutoScore |1.0.0 |1 | | |
|bayesdfa |1.3.3 |1 | | |
|bayesDP |1.3.6 |1 | | |
|BayesianFactorZoo |0.0.0.2 |1 | | |
|BCClong |1.0.2 |1 | |1 |
|binsreg |1.0 |1 | | |
|bmstdr |0.7.9 |1 | | |
|bspcov |1.0.0 |1 | | |
|CalibrationCurves |2.0.1 |1 | | |
|Canek |? | | | |
|CARBayesST |4.0 |1 | | |
|CaseBasedReasoning |0.3 |1 | | |
|cellpypes |? | | | |
|CGPfunctions |0.6.3 |1 | | |
|CIARA |? | | | |
|ClustAssess |? | | | |
|clustree |? | | | |
|cmprskcoxmsm |0.2.1 |1 | | |
|combiroc |? | | | |
|conos |? | | | |
|contrast |0.24.2 |1 | | |
|countland |? | | | |
|coxed |0.3.3 |1 | | |
|CRMetrics |? | | | |
|csmpv |1.0.3 |1 | | |
|ctsem |3.10.0 |1 | | |
|CytoSimplex |? | | | |
|DepthProc |2.1.5 |1 | | |
|DIscBIO |? | | | |
|DR.SC |? | | | |
|dyngen |? | | | |
|EcoEnsemble |1.0.5 |1 | | |
|ecolottery |1.0.0 |1 | | |
|EpiEstim |2.2-4 |1 | | |
|evolqg |0.3-4 |1 | | |
|ForecastComb |1.3.1 |1 | | |
|gapfill |0.9.6-1 |1 | |1 |
|GeomComb |1.0 |1 | | |
|[geostan](failures.md#geostan)|0.6.1 |__+1__ | |-3 |
|ggrcs |0.3.8 |1 | | |
|ggrisk |1.3 |1 | | |
|ggsector |? | | | |
|gJLS2 |0.2.0 |1 | | |
|grandR |? | | | |
|Greg |2.0.2 |1 | | |
|greport |0.7-4 |1 | | |
|harmony |? | | | |
|hettx |0.1.3 |1 | | |
|hIRT |0.3.0 |1 | | |
|Hmsc |3.0-13 |1 | | |
|iNZightPlots |2.15.3 |1 | | |
|iNZightRegression |1.3.4 |1 | | |
|IRexamples |0.0.4 |1 | | |
|joineRML |0.4.6 |1 | | |
|JWileymisc |1.4.1 |1 | | |
|kmc |0.4-2 |1 | | |
|L2E |2.0 |1 | | |
|llbayesireg |1.0.0 |1 | | |
|LorenzRegression |1.0.0 |1 | | |
|lsirm12pl |1.3.1 |1 | | |
|mbsts |3.0 |1 | | |
|MendelianRandomization |0.10.0 |1 | | |
|MetabolicSurv |1.1.2 |1 | | |
|miWQS |0.4.4 |1 | | |
|mlmts |1.1.1 |1 | | |
|MRZero |0.2.0 |1 | | |
|Multiaovbay |0.1.0 |1 | | |
|multilevelTools |0.1.1 |1 | | |
|multinma |0.7.0 |1 | | |
|NCA |4.0.1 |1 | | |
|netcmc |1.0.2 |1 | | |
|NetworkChange |0.8 |1 | | |
|nlmeVPC |2.6 |1 | | |
|NMADiagT |0.1.2 |1 | | |
|optweight |0.2.5 |1 | | |
|OVtool |1.0.3 |1 | | |
|paths |0.1.1 |1 | | |
|PLMIX |2.1.1 |1 | | |
|popstudy |1.0.1 |1 | | |
|pould |1.0.1 |1 | | |
|powerly |1.8.6 |1 | | |
|pre |1.0.7 |1 | | |
|PRECAST |? | | | |
|ProFAST |? | | | |
|pscore |0.4.0 |1 | | |
|psfmi |1.4.0 |1 | | |
|qreport |1.0-0 |1 | | |
|qris |1.1.1 |1 | | |
|qte |1.3.1 |1 | | |
|quid |0.0.1 |1 | | |
|RATest |0.1.10 |1 | | |
|RcmdrPlugin.RiskDemo |3.2 |1 | | |
|rddtools |1.6.0 |1 | | |
|riskRegression |2023.12.21 |1 | | |
|rliger |? | | | |
|rms |6.8-0 |1 | |1 |
|rmsb |1.1-0 |1 | | |
|robmed |1.0.2 |1 | | |
|robmedExtra |0.1.0 |1 | | |
|RPPanalyzer |1.4.9 |1 | | |
|rstanarm |2.32.1 |1 | | |
|scCustomize |? | | | |
|SCdeconR |? | | | |
|scDiffCom |? | | | |
|scGate |? | | | |
|scMappR |? | | | |
|SCORPIUS |? | | | |
|scpoisson |? | | | |
|SCpubr |? | | | |
|scRNAstat |? | | | |
|sectorgap |0.1.0 |1 | | |
|SEERaBomb |2019.2 |1 | | |
|semicmprskcoxmsm |0.2.0 |1 | | |
|SensMap |0.7 |1 | | |
|Signac |? | | | |
|SimplyAgree |0.2.0 |1 | | |
|sMSROC |0.1.2 |1 | | |
|SNPassoc |2.1-0 |1 | | |
|snplinkage |? | | | |
|SoupX |? | | | |
|SpaDES.core |2.0.5 |1 | | |
|sparsereg |1.2 |1 | | |
|SPECK |? | | | |
|spikeSlabGAM |1.1-19 |1 | | |
|statsr |0.3.0 |1 | | |
|streamDAG |? | | | |
|survHE |2.0.1 |1 | |1 |
|survidm |1.3.2 |1 | | |
|tempted |0.1.1 |1 | | |
|[tidydr](failures.md#tidydr)|0.0.5 |__+1__ | | |
|tidyEdSurvey |0.1.3 |1 | | |
|tidyseurat |? | | | |
|tidyvpc |1.5.1 |1 | | |
|treefit |? | | | |
|TriDimRegression |1.0.2 |1 | | |
|TSrepr |1.1.0 |1 | | |
|twang |2.6 |1 | | |
|valse |0.1-0 |1 | | |
|vdg |1.2.3 |1 | | |
|WRTDStidal |1.1.4 |1 | | |

## New problems (5)
## New problems (64)

|package |version |error |warning |note |
|:----------------------|:-------|:------|:-------|:------|
|[ggh4x](problems.md#ggh4x)|0.2.8 |__+3__ | | |
|[MplusAutomation](problems.md#mplusautomation)|1.1.1 | | |__+1__ |
|[PlasmaMutationDetector](problems.md#plasmamutationdetector)|1.7.2 | | |__+1__ |
|[Superpower](problems.md#superpower)|0.2.0 |__+1__ | |1 |
|[xaringanthemer](problems.md#xaringanthemer)|0.4.2 |__+1__ | | |
|package |version |error |warning |note |
|:---------------|:--------|:--------|:--------|:--------|
|[asmbPLS](problems.md#asmbpls)|1.0.0 | |__+1__ |1 |
|[bdl](problems.md#bdl)|1.0.5 | |__+1__ | |
|[bdscale](problems.md#bdscale)|2.0.0 |__+1__ | |__+1__ |
|[biclustermd](problems.md#biclustermd)|0.2.3 |__+1__ | |1 |
|[brolgar](problems.md#brolgar)|1.0.1 |__+2__ | |__+1__ |
|[bSi](problems.md#bsi)|1.0.0 | |__+1__ | |
|[CausalImpact](problems.md#causalimpact)|1.3.0 |__+2__ | |__+1__ |
|[ClusROC](problems.md#clusroc)|1.0.2 | |__+1__ | |
|[clustEff](problems.md#clusteff)|0.3.1 | |__+1__ | |
|[CLVTools](problems.md#clvtools)|0.10.0 |__+1__ | |1 __+1__ |
|[coda4microbiome](problems.md#coda4microbiome)|0.2.3 | |__+1__ | |
|[CompAREdesign](problems.md#comparedesign)|2.3.1 | |__+1__ | |
|[covidcast](problems.md#covidcast)|0.5.2 |__+2__ | |1 __+1__ |
|[Coxmos](problems.md#coxmos)|1.0.2 |1 |__+1__ |1 |
|[csa](problems.md#csa)|0.7.1 | |__+1__ | |
|[deeptime](problems.md#deeptime)|1.1.1 |__+2__ | | |
|[DEGRE](problems.md#degre)|0.2.0 | |__+1__ | |
|[did](problems.md#did)|2.1.2 | |1 __+1__ | |
|[EpiCurve](problems.md#epicurve)|2.4-2 |__+1__ | |1 __+1__ |
|[epiR](problems.md#epir)|2.0.74 |__+1__ | |__+1__ |
|[FuncNN](problems.md#funcnn)|1.0 | |__+1__ |1 |
|[ggedit](problems.md#ggedit)|0.4.1 |__+1__ | | |
|[ggfixest](problems.md#ggfixest)|0.1.0 |1 __+1__ | | |
|[ggfortify](problems.md#ggfortify)|0.4.17 | | |__+1__ |
|[ggh4x](problems.md#ggh4x)|0.2.8 |1 __+2__ | |__+1__ |
|[ggheatmap](problems.md#ggheatmap)|2.2 | |__+1__ | |
|[ggScatRidges](problems.md#ggscatridges)|0.1.1 | |__+1__ | |
|[GimmeMyPlot](problems.md#gimmemyplot)|0.1.0 | |__+1__ | |
|[hilldiv](problems.md#hilldiv)|1.5.1 | |__+1__ | |
|[hJAM](problems.md#hjam)|1.0.0 | |__+1__ | |
|[iglu](problems.md#iglu)|4.0.0 |__+2__ | |__+1__ |
|[ImFoR](problems.md#imfor)|0.1.0 | |__+1__ | |
|[iNEXT.4steps](problems.md#inext4steps)|1.0.0 | |__+1__ | |
|[insane](problems.md#insane)|1.0.3 | |__+1__ | |
|[MarketMatching](problems.md#marketmatching)|1.2.1 |__+1__ | | |
|[mc2d](problems.md#mc2d)|0.2.0 | |__+1__ |1 |
|[MetaIntegrator](problems.md#metaintegrator)|2.1.3 | |__+1__ |2 |
|[MF.beta4](problems.md#mfbeta4)|1.0.3 | |1 __+1__ | |
|[MIMSunit](problems.md#mimsunit)|0.11.2 |__+1__ | | |
|[missingHE](problems.md#missinghe)|1.5.0 | |__+1__ |1 |
|[MSPRT](problems.md#msprt)|3.0 | |__+1__ |1 |
|[nzelect](problems.md#nzelect)|0.4.0 |__+1__ | |2 |
|[OenoKPM](problems.md#oenokpm)|2.4.1 | |__+1__ | |
|[posologyr](problems.md#posologyr)|1.2.4 |__+1__ | | |
|[qicharts](problems.md#qicharts)|0.5.8 |__+1__ | | |
|[qicharts2](problems.md#qicharts2)|0.7.5 |__+1__ | |__+1__ |
|[QuadratiK](problems.md#quadratik)|1.1.0 | |__+1__ |1 |
|[RCTrep](problems.md#rctrep)|1.2.0 | |__+1__ | |
|[scdtb](problems.md#scdtb)|0.1.0 |__+1__ | | |
|[SCOUTer](problems.md#scouter)|1.0.0 | |__+1__ | |
|[sievePH](problems.md#sieveph)|1.0.4 | |__+1__ | |
|[SouthParkRshiny](problems.md#southparkrshiny)|1.0.0 | |__+1__ |2 |
|[SqueakR](problems.md#squeakr)|1.3.0 |1 |__+1__ |1 |
|[survminer](problems.md#survminer)|0.4.9 | |__+1__ |1 |
|[symptomcheckR](problems.md#symptomcheckr)|0.1.3 | |__+1__ | |
|[tcgaViz](problems.md#tcgaviz)|1.0.2 | |__+1__ | |
|[TestGardener](problems.md#testgardener)|3.3.3 | |__+1__ | |
|[tis](problems.md#tis)|1.39 |__+1__ | |1 |
|[UniprotR](problems.md#uniprotr)|2.4.0 | |__+1__ | |
|[VALERIE](problems.md#valerie)|1.1.0 | |__+1__ |1 |
|[vannstats](problems.md#vannstats)|1.3.4.14 | |__+1__ | |
|[vici](problems.md#vici)|0.7.3 | |__+1__ | |
|[Wats](problems.md#wats)|1.0.1 |__+2__ | |__+1__ |
|[xaringanthemer](problems.md#xaringanthemer)|0.4.2 |1 __+1__ | | |

Loading
Loading