Skip to content

Commit 46ae89f

Browse files
teunbrandthomasp85
andauthored
Consolidate scale definition of position aesthetics (#5640)
* Position scales use ggplot_global for aesthetics * Run revdepcheck * Fallbacks for numeric inputs * add news bullet * improve warning * add test --------- Co-authored-by: Thomas Lin Pedersen <[email protected]>
1 parent b8da7af commit 46ae89f

File tree

8 files changed

+12594
-750
lines changed

8 files changed

+12594
-750
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# ggplot2 (development version)
22

3+
* All position scales now use the same definition of `x` and `y` aesthetics.
4+
This lets uncommon aesthetics like `xintercept` expand scales as usual.
5+
(#3342, #4966, @teunbrand)
6+
* Bare numeric values provided to Date or Datetime scales get inversely
7+
transformed (cast to Date/POSIXct) with a warning (@teunbrand).
38
* `stat_bin()` now accepts functions for argument `breaks` (@aijordan, #4561)
49
* (internal) The plot's layout now has a coord parameter that is used to
510
prevent setting up identical panel parameters (#5427)

R/scale-date.R

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ scale_x_date <- function(name = waiver(),
8181
sec.axis = waiver()) {
8282

8383
sc <- datetime_scale(
84-
c("x", "xmin", "xmax", "xend"),
84+
ggplot_global$x_aes,
8585
"date",
8686
name = name,
8787
palette = identity,
@@ -118,7 +118,7 @@ scale_y_date <- function(name = waiver(),
118118
sec.axis = waiver()) {
119119

120120
sc <- datetime_scale(
121-
c("y", "ymin", "ymax", "yend"),
121+
ggplot_global$y_aes,
122122
"date",
123123
name = name,
124124
palette = identity,
@@ -156,7 +156,7 @@ scale_x_datetime <- function(name = waiver(),
156156
sec.axis = waiver()) {
157157

158158
sc <- datetime_scale(
159-
c("x", "xmin", "xmax", "xend"),
159+
ggplot_global$x_aes,
160160
"time",
161161
name = name,
162162
palette = identity,
@@ -196,7 +196,7 @@ scale_y_datetime <- function(name = waiver(),
196196
sec.axis = waiver()) {
197197

198198
sc <- datetime_scale(
199-
c("y", "ymin", "ymax", "yend"),
199+
ggplot_global$y_aes,
200200
"time",
201201
name = name,
202202
palette = identity,
@@ -317,7 +317,7 @@ datetime_scale <- function(aesthetics, transform, trans = deprecated(),
317317

318318
# x/y position aesthetics should use ScaleContinuousDate or
319319
# ScaleContinuousDatetime; others use ScaleContinuous
320-
if (all(aesthetics %in% c("x", "xmin", "xmax", "xend", "y", "ymin", "ymax", "yend"))) {
320+
if (all(aesthetics %in% c(ggplot_global$x_aes, ggplot_global$y_aes))) {
321321
scale_class <- switch(
322322
transform,
323323
date = ScaleContinuousDate,
@@ -362,6 +362,13 @@ ScaleContinuousDatetime <- ggproto("ScaleContinuousDatetime", ScaleContinuous,
362362
self$timezone <- tz
363363
self$trans <- transform_time(self$timezone)
364364
}
365+
if (is_bare_numeric(x)) {
366+
x <- self$trans$inverse(x)
367+
cli::cli_warn(c(
368+
"A {.cls numeric} value was passed to a {.field Datetime} scale.",
369+
i = "The value was converted to {obj_type_friendly(x)}."
370+
), call = self$call)
371+
}
365372
ggproto_parent(ScaleContinuous, self)$transform(x)
366373
},
367374
map = function(self, x, limits = self$get_limits()) {
@@ -401,6 +408,16 @@ ScaleContinuousDate <- ggproto("ScaleContinuousDate", ScaleContinuous,
401408
map = function(self, x, limits = self$get_limits()) {
402409
self$oob(x, limits)
403410
},
411+
transform = function(self, x) {
412+
if (is_bare_numeric(x)) {
413+
x <- self$trans$inverse(x)
414+
cli::cli_warn(c(
415+
"A {.cls numeric} value was passed to a {.field Date} scale.",
416+
i = "The value was converted to {obj_type_friendly(x)}."
417+
), call = self$call)
418+
}
419+
ggproto_parent(ScaleContinuous, self)$transform(x)
420+
},
404421
get_breaks = function(self, limits = self$get_limits()) {
405422
breaks <- ggproto_parent(ScaleContinuous, self)$get_breaks(limits)
406423
if (is.null(breaks)) {

R/scale-discrete-.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ scale_x_discrete <- function(name = waiver(), ..., palette = seq_len,
7171
expand = waiver(), guide = waiver(),
7272
position = "bottom", sec.axis = waiver()) {
7373
sc <- discrete_scale(
74-
aesthetics = c("x", "xmin", "xmax", "xend"), name = name,
74+
aesthetics = ggplot_global$x_aes, name = name,
7575
palette = palette, ...,
7676
expand = expand, guide = guide, position = position,
7777
super = ScaleDiscretePosition
@@ -86,7 +86,7 @@ scale_y_discrete <- function(name = waiver(), ..., palette = seq_len,
8686
expand = waiver(), guide = waiver(),
8787
position = "left", sec.axis = waiver()) {
8888
sc <- discrete_scale(
89-
aesthetics = c("y", "ymin", "ymax", "yend"), name = name,
89+
aesthetics = ggplot_global$y_aes, name = name,
9090
palette = palette, ...,
9191
expand = expand, guide = guide, position = position,
9292
super = ScaleDiscretePosition

revdep/README.md

Lines changed: 216 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,222 @@
11
# Revdeps
22

3-
## Failed to check (17)
3+
## Failed to check (146)
44

5-
|package |version |error |warning |note |
6-
|:----------------|:-------|:-----|:-------|:----|
7-
|bayesdfa |1.3.3 |1 | | |
8-
|bmgarch |2.0.0 |1 | | |
9-
|ctsem |3.9.1 |1 | | |
10-
|EcoEnsemble |1.0.5 |1 | | |
11-
|geostan |0.5.4 |1 | | |
12-
|grandR |? | | | |
13-
|multilevelcoda |1.2.3 |1 | | |
14-
|multinma |0.6.1 |1 | | |
15-
|rmsb |1.1-0 |1 | | |
16-
|rstanarm |2.32.1 |1 | | |
17-
|Seurat |? | | | |
18-
|streamDAG |? | | | |
19-
|treestats |1.0.5 |1 | | |
20-
|TriDimRegression |1.0.2 |1 | | |
21-
|triptych |0.1.2 |1 | | |
22-
|ubms |1.2.6 |1 | | |
23-
|valse |0.1-0 |1 | | |
5+
|package |version |error |warning |note |
6+
|:----------------------|:----------|:------|:-------|:----|
7+
|abctools |1.1.7 |1 | | |
8+
|AnanseSeurat |? | | | |
9+
|animalEKF |1.2 |1 | | |
10+
|ANOM |0.5 |1 | | |
11+
|APackOfTheClones |? | | | |
12+
|atRisk |0.1.0 |1 | | |
13+
|AutoScore |1.0.0 |1 | | |
14+
|bayesdfa |1.3.3 |1 | | |
15+
|bayesDP |1.3.6 |1 | | |
16+
|BayesianFactorZoo |0.0.0.2 |1 | | |
17+
|BCClong |1.0.2 |1 | |1 |
18+
|binsreg |1.0 |1 | | |
19+
|bmstdr |0.7.9 |1 | | |
20+
|bspcov |1.0.0 |1 | | |
21+
|CalibrationCurves |2.0.1 |1 | | |
22+
|Canek |? | | | |
23+
|CARBayesST |4.0 |1 | | |
24+
|CaseBasedReasoning |0.3 |1 | | |
25+
|cellpypes |? | | | |
26+
|CGPfunctions |0.6.3 |1 | | |
27+
|CIARA |? | | | |
28+
|ClustAssess |? | | | |
29+
|clustree |? | | | |
30+
|cmprskcoxmsm |0.2.1 |1 | | |
31+
|combiroc |? | | | |
32+
|conos |? | | | |
33+
|contrast |0.24.2 |1 | | |
34+
|countland |? | | | |
35+
|coxed |0.3.3 |1 | | |
36+
|CRMetrics |? | | | |
37+
|csmpv |1.0.3 |1 | | |
38+
|ctsem |3.10.0 |1 | | |
39+
|CytoSimplex |? | | | |
40+
|DepthProc |2.1.5 |1 | | |
41+
|DIscBIO |? | | | |
42+
|DR.SC |? | | | |
43+
|dyngen |? | | | |
44+
|EcoEnsemble |1.0.5 |1 | | |
45+
|ecolottery |1.0.0 |1 | | |
46+
|EpiEstim |2.2-4 |1 | | |
47+
|evolqg |0.3-4 |1 | | |
48+
|ForecastComb |1.3.1 |1 | | |
49+
|gapfill |0.9.6-1 |1 | |1 |
50+
|GeomComb |1.0 |1 | | |
51+
|[geostan](failures.md#geostan)|0.6.1 |__+1__ | |-3 |
52+
|ggrcs |0.3.8 |1 | | |
53+
|ggrisk |1.3 |1 | | |
54+
|ggsector |? | | | |
55+
|gJLS2 |0.2.0 |1 | | |
56+
|grandR |? | | | |
57+
|Greg |2.0.2 |1 | | |
58+
|greport |0.7-4 |1 | | |
59+
|harmony |? | | | |
60+
|hettx |0.1.3 |1 | | |
61+
|hIRT |0.3.0 |1 | | |
62+
|Hmsc |3.0-13 |1 | | |
63+
|iNZightPlots |2.15.3 |1 | | |
64+
|iNZightRegression |1.3.4 |1 | | |
65+
|IRexamples |0.0.4 |1 | | |
66+
|joineRML |0.4.6 |1 | | |
67+
|JWileymisc |1.4.1 |1 | | |
68+
|kmc |0.4-2 |1 | | |
69+
|L2E |2.0 |1 | | |
70+
|llbayesireg |1.0.0 |1 | | |
71+
|LorenzRegression |1.0.0 |1 | | |
72+
|lsirm12pl |1.3.1 |1 | | |
73+
|mbsts |3.0 |1 | | |
74+
|MendelianRandomization |0.10.0 |1 | | |
75+
|MetabolicSurv |1.1.2 |1 | | |
76+
|miWQS |0.4.4 |1 | | |
77+
|mlmts |1.1.1 |1 | | |
78+
|MRZero |0.2.0 |1 | | |
79+
|Multiaovbay |0.1.0 |1 | | |
80+
|multilevelTools |0.1.1 |1 | | |
81+
|multinma |0.7.0 |1 | | |
82+
|NCA |4.0.1 |1 | | |
83+
|netcmc |1.0.2 |1 | | |
84+
|NetworkChange |0.8 |1 | | |
85+
|nlmeVPC |2.6 |1 | | |
86+
|NMADiagT |0.1.2 |1 | | |
87+
|optweight |0.2.5 |1 | | |
88+
|OVtool |1.0.3 |1 | | |
89+
|paths |0.1.1 |1 | | |
90+
|PLMIX |2.1.1 |1 | | |
91+
|popstudy |1.0.1 |1 | | |
92+
|pould |1.0.1 |1 | | |
93+
|powerly |1.8.6 |1 | | |
94+
|pre |1.0.7 |1 | | |
95+
|PRECAST |? | | | |
96+
|ProFAST |? | | | |
97+
|pscore |0.4.0 |1 | | |
98+
|psfmi |1.4.0 |1 | | |
99+
|qreport |1.0-0 |1 | | |
100+
|qris |1.1.1 |1 | | |
101+
|qte |1.3.1 |1 | | |
102+
|quid |0.0.1 |1 | | |
103+
|RATest |0.1.10 |1 | | |
104+
|RcmdrPlugin.RiskDemo |3.2 |1 | | |
105+
|rddtools |1.6.0 |1 | | |
106+
|riskRegression |2023.12.21 |1 | | |
107+
|rliger |? | | | |
108+
|rms |6.8-0 |1 | |1 |
109+
|rmsb |1.1-0 |1 | | |
110+
|robmed |1.0.2 |1 | | |
111+
|robmedExtra |0.1.0 |1 | | |
112+
|RPPanalyzer |1.4.9 |1 | | |
113+
|rstanarm |2.32.1 |1 | | |
114+
|scCustomize |? | | | |
115+
|SCdeconR |? | | | |
116+
|scDiffCom |? | | | |
117+
|scGate |? | | | |
118+
|scMappR |? | | | |
119+
|SCORPIUS |? | | | |
120+
|scpoisson |? | | | |
121+
|SCpubr |? | | | |
122+
|scRNAstat |? | | | |
123+
|sectorgap |0.1.0 |1 | | |
124+
|SEERaBomb |2019.2 |1 | | |
125+
|semicmprskcoxmsm |0.2.0 |1 | | |
126+
|SensMap |0.7 |1 | | |
127+
|Signac |? | | | |
128+
|SimplyAgree |0.2.0 |1 | | |
129+
|sMSROC |0.1.2 |1 | | |
130+
|SNPassoc |2.1-0 |1 | | |
131+
|snplinkage |? | | | |
132+
|SoupX |? | | | |
133+
|SpaDES.core |2.0.5 |1 | | |
134+
|sparsereg |1.2 |1 | | |
135+
|SPECK |? | | | |
136+
|spikeSlabGAM |1.1-19 |1 | | |
137+
|statsr |0.3.0 |1 | | |
138+
|streamDAG |? | | | |
139+
|survHE |2.0.1 |1 | |1 |
140+
|survidm |1.3.2 |1 | | |
141+
|tempted |0.1.1 |1 | | |
142+
|[tidydr](failures.md#tidydr)|0.0.5 |__+1__ | | |
143+
|tidyEdSurvey |0.1.3 |1 | | |
144+
|tidyseurat |? | | | |
145+
|tidyvpc |1.5.1 |1 | | |
146+
|treefit |? | | | |
147+
|TriDimRegression |1.0.2 |1 | | |
148+
|TSrepr |1.1.0 |1 | | |
149+
|twang |2.6 |1 | | |
150+
|valse |0.1-0 |1 | | |
151+
|vdg |1.2.3 |1 | | |
152+
|WRTDStidal |1.1.4 |1 | | |
24153

25-
## New problems (5)
154+
## New problems (64)
26155

27-
|package |version |error |warning |note |
28-
|:----------------------|:-------|:------|:-------|:------|
29-
|[ggh4x](problems.md#ggh4x)|0.2.8 |__+3__ | | |
30-
|[MplusAutomation](problems.md#mplusautomation)|1.1.1 | | |__+1__ |
31-
|[PlasmaMutationDetector](problems.md#plasmamutationdetector)|1.7.2 | | |__+1__ |
32-
|[Superpower](problems.md#superpower)|0.2.0 |__+1__ | |1 |
33-
|[xaringanthemer](problems.md#xaringanthemer)|0.4.2 |__+1__ | | |
156+
|package |version |error |warning |note |
157+
|:---------------|:--------|:--------|:--------|:--------|
158+
|[asmbPLS](problems.md#asmbpls)|1.0.0 | |__+1__ |1 |
159+
|[bdl](problems.md#bdl)|1.0.5 | |__+1__ | |
160+
|[bdscale](problems.md#bdscale)|2.0.0 |__+1__ | |__+1__ |
161+
|[biclustermd](problems.md#biclustermd)|0.2.3 |__+1__ | |1 |
162+
|[brolgar](problems.md#brolgar)|1.0.1 |__+2__ | |__+1__ |
163+
|[bSi](problems.md#bsi)|1.0.0 | |__+1__ | |
164+
|[CausalImpact](problems.md#causalimpact)|1.3.0 |__+2__ | |__+1__ |
165+
|[ClusROC](problems.md#clusroc)|1.0.2 | |__+1__ | |
166+
|[clustEff](problems.md#clusteff)|0.3.1 | |__+1__ | |
167+
|[CLVTools](problems.md#clvtools)|0.10.0 |__+1__ | |1 __+1__ |
168+
|[coda4microbiome](problems.md#coda4microbiome)|0.2.3 | |__+1__ | |
169+
|[CompAREdesign](problems.md#comparedesign)|2.3.1 | |__+1__ | |
170+
|[covidcast](problems.md#covidcast)|0.5.2 |__+2__ | |1 __+1__ |
171+
|[Coxmos](problems.md#coxmos)|1.0.2 |1 |__+1__ |1 |
172+
|[csa](problems.md#csa)|0.7.1 | |__+1__ | |
173+
|[deeptime](problems.md#deeptime)|1.1.1 |__+2__ | | |
174+
|[DEGRE](problems.md#degre)|0.2.0 | |__+1__ | |
175+
|[did](problems.md#did)|2.1.2 | |1 __+1__ | |
176+
|[EpiCurve](problems.md#epicurve)|2.4-2 |__+1__ | |1 __+1__ |
177+
|[epiR](problems.md#epir)|2.0.74 |__+1__ | |__+1__ |
178+
|[FuncNN](problems.md#funcnn)|1.0 | |__+1__ |1 |
179+
|[ggedit](problems.md#ggedit)|0.4.1 |__+1__ | | |
180+
|[ggfixest](problems.md#ggfixest)|0.1.0 |1 __+1__ | | |
181+
|[ggfortify](problems.md#ggfortify)|0.4.17 | | |__+1__ |
182+
|[ggh4x](problems.md#ggh4x)|0.2.8 |1 __+2__ | |__+1__ |
183+
|[ggheatmap](problems.md#ggheatmap)|2.2 | |__+1__ | |
184+
|[ggScatRidges](problems.md#ggscatridges)|0.1.1 | |__+1__ | |
185+
|[GimmeMyPlot](problems.md#gimmemyplot)|0.1.0 | |__+1__ | |
186+
|[hilldiv](problems.md#hilldiv)|1.5.1 | |__+1__ | |
187+
|[hJAM](problems.md#hjam)|1.0.0 | |__+1__ | |
188+
|[iglu](problems.md#iglu)|4.0.0 |__+2__ | |__+1__ |
189+
|[ImFoR](problems.md#imfor)|0.1.0 | |__+1__ | |
190+
|[iNEXT.4steps](problems.md#inext4steps)|1.0.0 | |__+1__ | |
191+
|[insane](problems.md#insane)|1.0.3 | |__+1__ | |
192+
|[MarketMatching](problems.md#marketmatching)|1.2.1 |__+1__ | | |
193+
|[mc2d](problems.md#mc2d)|0.2.0 | |__+1__ |1 |
194+
|[MetaIntegrator](problems.md#metaintegrator)|2.1.3 | |__+1__ |2 |
195+
|[MF.beta4](problems.md#mfbeta4)|1.0.3 | |1 __+1__ | |
196+
|[MIMSunit](problems.md#mimsunit)|0.11.2 |__+1__ | | |
197+
|[missingHE](problems.md#missinghe)|1.5.0 | |__+1__ |1 |
198+
|[MSPRT](problems.md#msprt)|3.0 | |__+1__ |1 |
199+
|[nzelect](problems.md#nzelect)|0.4.0 |__+1__ | |2 |
200+
|[OenoKPM](problems.md#oenokpm)|2.4.1 | |__+1__ | |
201+
|[posologyr](problems.md#posologyr)|1.2.4 |__+1__ | | |
202+
|[qicharts](problems.md#qicharts)|0.5.8 |__+1__ | | |
203+
|[qicharts2](problems.md#qicharts2)|0.7.5 |__+1__ | |__+1__ |
204+
|[QuadratiK](problems.md#quadratik)|1.1.0 | |__+1__ |1 |
205+
|[RCTrep](problems.md#rctrep)|1.2.0 | |__+1__ | |
206+
|[scdtb](problems.md#scdtb)|0.1.0 |__+1__ | | |
207+
|[SCOUTer](problems.md#scouter)|1.0.0 | |__+1__ | |
208+
|[sievePH](problems.md#sieveph)|1.0.4 | |__+1__ | |
209+
|[SouthParkRshiny](problems.md#southparkrshiny)|1.0.0 | |__+1__ |2 |
210+
|[SqueakR](problems.md#squeakr)|1.3.0 |1 |__+1__ |1 |
211+
|[survminer](problems.md#survminer)|0.4.9 | |__+1__ |1 |
212+
|[symptomcheckR](problems.md#symptomcheckr)|0.1.3 | |__+1__ | |
213+
|[tcgaViz](problems.md#tcgaviz)|1.0.2 | |__+1__ | |
214+
|[TestGardener](problems.md#testgardener)|3.3.3 | |__+1__ | |
215+
|[tis](problems.md#tis)|1.39 |__+1__ | |1 |
216+
|[UniprotR](problems.md#uniprotr)|2.4.0 | |__+1__ | |
217+
|[VALERIE](problems.md#valerie)|1.1.0 | |__+1__ |1 |
218+
|[vannstats](problems.md#vannstats)|1.3.4.14 | |__+1__ | |
219+
|[vici](problems.md#vici)|0.7.3 | |__+1__ | |
220+
|[Wats](problems.md#wats)|1.0.1 |__+2__ | |__+1__ |
221+
|[xaringanthemer](problems.md#xaringanthemer)|0.4.2 |1 __+1__ | | |
34222

0 commit comments

Comments
 (0)