@@ -123,20 +123,36 @@ scale_date_yq <- function(
123123 limits = NULL ,
124124 position = " bottom"
125125){
126- ggplot2 :: continuous_scale(
127- aesthetics ,
128- scale_name = " date_yq" ,
129- name = name ,
130- palette = identity ,
131- labels = labels ,
132- guide = default_guide(),
133- trans = date_yq_trans ,
134- super = ggplot2 :: ScaleContinuousDate ,
135- position = position ,
136- limits = limits ,
137- breaks = breaks ,
138- expand = c(0.04 , 0 )
139- )
126+ if (utils :: packageVersion(" ggplot2" ) < " 3.5.0" ){
127+ ggplot2 :: continuous_scale(
128+ aesthetics ,
129+ scale_name = " date_yq" ,
130+ name = name ,
131+ palette = identity ,
132+ labels = labels ,
133+ guide = default_guide(),
134+ trans = date_yq_trans ,
135+ super = ggplot2 :: ScaleContinuousDate ,
136+ position = position ,
137+ limits = limits ,
138+ breaks = breaks ,
139+ expand = c(0.04 , 0 )
140+ )
141+ } else {
142+ ggplot2 :: continuous_scale(
143+ aesthetics ,
144+ name = name ,
145+ palette = identity ,
146+ labels = labels ,
147+ guide = default_guide(),
148+ transform = date_yq_trans ,
149+ super = ggplot2 :: ScaleContinuousDate ,
150+ position = position ,
151+ limits = limits ,
152+ breaks = breaks ,
153+ expand = c(0.04 , 0 )
154+ )
155+ }
140156}
141157
142158
@@ -196,20 +212,36 @@ scale_date_ym <- function(
196212 limits = NULL ,
197213 position = " left"
198214){
199- ggplot2 :: continuous_scale(
200- aesthetics ,
201- scale_name = " date_ym" ,
202- name = name ,
203- breaks = breaks ,
204- palette = identity ,
205- labels = labels ,
206- guide = default_guide(),
207- trans = date_ym_trans ,
208- super = ggplot2 :: ScaleContinuousDate ,
209- position = position ,
210- limits = limits ,
211- expand = c(0.04 , 0 )
212- )
215+ if (utils :: packageVersion(" ggplot2" ) < " 3.5.0" ){
216+ ggplot2 :: continuous_scale(
217+ aesthetics ,
218+ scale_name = " date_ym" ,
219+ name = name ,
220+ breaks = breaks ,
221+ palette = identity ,
222+ labels = labels ,
223+ guide = default_guide(),
224+ trans = date_ym_trans ,
225+ super = ggplot2 :: ScaleContinuousDate ,
226+ position = position ,
227+ limits = limits ,
228+ expand = c(0.04 , 0 )
229+ )
230+ } else {
231+ ggplot2 :: continuous_scale(
232+ aesthetics ,
233+ name = name ,
234+ breaks = breaks ,
235+ palette = identity ,
236+ labels = labels ,
237+ guide = default_guide(),
238+ transform = date_ym_trans ,
239+ super = ggplot2 :: ScaleContinuousDate ,
240+ position = position ,
241+ limits = limits ,
242+ expand = c(0.04 , 0 )
243+ )
244+ }
213245}
214246
215247
@@ -266,20 +298,36 @@ scale_date_yw <- function(
266298 limits = NULL ,
267299 position = " bottom"
268300){
269- ggplot2 :: continuous_scale(
270- aesthetics ,
271- scale_name = " date_yw" ,
272- name = name ,
273- breaks = breaks ,
274- palette = identity ,
275- guide = default_guide(),
276- labels = labels ,
277- trans = date_yw_trans ,
278- super = ggplot2 :: ScaleContinuousDate ,
279- position = position ,
280- limits = limits ,
281- expand = ggplot2 :: waiver()
282- )
301+ if (utils :: packageVersion(" ggplot2" ) < " 3.5.0" ){
302+ ggplot2 :: continuous_scale(
303+ aesthetics ,
304+ scale_name = " date_yw" ,
305+ name = name ,
306+ breaks = breaks ,
307+ palette = identity ,
308+ guide = default_guide(),
309+ labels = labels ,
310+ trans = date_yw_trans ,
311+ super = ggplot2 :: ScaleContinuousDate ,
312+ position = position ,
313+ limits = limits ,
314+ expand = ggplot2 :: waiver()
315+ )
316+ } else {
317+ ggplot2 :: continuous_scale(
318+ aesthetics ,
319+ name = name ,
320+ breaks = breaks ,
321+ palette = identity ,
322+ guide = default_guide(),
323+ labels = labels ,
324+ transform = date_yw_trans ,
325+ super = ggplot2 :: ScaleContinuousDate ,
326+ position = position ,
327+ limits = limits ,
328+ expand = ggplot2 :: waiver()
329+ )
330+ }
283331}
284332
285333
0 commit comments