3434
3535
3636# This tells ggplot2 what scale to look for
37+
3738scale_type.date_yq <- function (x ) " date_yq"
3839scale_type.date_ym <- function (x ) " date_ym"
3940scale_type.date_yw <- function (x ) " date_yw"
@@ -46,13 +47,15 @@ scale_type.date_yw <- function(x) "date_yw"
4647scale_x_date_yq <- function (
4748 name = " Quarter" ,
4849 breaks = date_yq_breaks(),
50+ labels = ggplot2 :: waiver(),
4951 limits = NULL ,
5052 position = " bottom"
5153){
5254 scale_date_yq(
5355 aesthetics = c(" x" , " xmin" , " xmax" , " xend" ),
5456 name = name ,
5557 limits = limits ,
58+ labels = labels ,
5659 breaks = breaks ,
5760 position = position
5861 )
@@ -66,13 +69,15 @@ scale_x_date_yq <- function(
6669scale_y_date_yq <- function (
6770 name = " Quarter" ,
6871 breaks = date_yq_breaks(),
72+ labels = ggplot2 :: waiver(),
6973 limits = NULL ,
7074 position = " left"
7175){
7276 scale_date_yq(
7377 aesthetics = c(" y" , " ymin" , " ymax" , " yend" ),
7478 name = name ,
7579 limits = limits ,
80+ labels = labels ,
7681 breaks = breaks ,
7782 position = position
7883 )
@@ -85,6 +90,7 @@ scale_date_yq <- function(
8590 aesthetics ,
8691 name = " Quarter" ,
8792 breaks = date_yq_breaks(),
93+ labels = ggplot2 :: waiver(),
8894 limits = NULL ,
8995 position = " bottom"
9096){
@@ -93,6 +99,7 @@ scale_date_yq <- function(
9399 scale_name = " date_yq" ,
94100 name = name ,
95101 palette = identity ,
102+ labels = labels ,
96103 guide = " none" ,
97104 trans = date_yq_trans ,
98105 super = ggplot2 :: ScaleContinuousDate ,
@@ -113,13 +120,15 @@ scale_date_yq <- function(
113120scale_x_date_ym <- function (
114121 name = " Month" ,
115122 breaks = date_ym_breaks(),
123+ labels = ggplot2 :: waiver(),
116124 limits = NULL ,
117125 position = " bottom"
118126){
119127 scale_date_ym(
120128 aesthetics = c(" x" , " xmin" , " xmax" , " xend" ),
121129 name = name ,
122130 breaks = breaks ,
131+ labels = labels ,
123132 limits = limits ,
124133 position = position
125134 )
@@ -133,13 +142,15 @@ scale_x_date_ym <- function(
133142scale_y_date_ym <- function (
134143 name = " Month" ,
135144 breaks = date_ym_breaks(),
145+ labels = ggplot2 :: waiver(),
136146 limits = NULL ,
137147 position = " left"
138148) {
139149 scale_date_ym(aesthetics = c(
140150 " y" , " ymin" , " ymax" , " yend" ),
141151 name = name ,
142152 breaks = breaks ,
153+ labels = labels ,
143154 limits = limits ,
144155 position = position
145156 )
@@ -152,6 +163,7 @@ scale_date_ym <- function(
152163 aesthetics ,
153164 name = " Month" ,
154165 breaks = date_ym_breaks(),
166+ labels = ggplot2 :: waiver(),
155167 limits = NULL ,
156168 position = " left"
157169){
@@ -161,6 +173,7 @@ scale_date_ym <- function(
161173 name = name ,
162174 breaks = breaks ,
163175 palette = identity ,
176+ labels = labels ,
164177 guide = " none" ,
165178 trans = date_ym_trans ,
166179 super = ggplot2 :: ScaleContinuousDate ,
@@ -176,15 +189,17 @@ scale_date_ym <- function(
176189# ' @rdname scale_date_xx
177190# ' @export
178191scale_x_date_yw <- function (
179- name = " Month " ,
192+ name = " Week " ,
180193 breaks = date_yw_breaks(),
194+ labels = ggplot2 :: waiver(),
181195 limits = NULL ,
182196 position = " bottom"
183197){
184198 scale_date_yw(
185199 aesthetics = c(" x" , " xmin" , " xmax" , " xend" ),
186200 name = name ,
187201 breaks = breaks ,
202+ labels = labels ,
188203 limits = limits ,
189204 position = position
190205 )
@@ -196,8 +211,9 @@ scale_x_date_yw <- function(
196211# ' @rdname scale_date_xx
197212# ' @export
198213scale_y_date_yw <- function (
199- name = " Month " ,
214+ name = " Week " ,
200215 breaks = date_yw_breaks(),
216+ labels = ggplot2 :: waiver(),
201217 limits = NULL ,
202218 position = " left"
203219){
@@ -217,6 +233,7 @@ scale_date_yw <- function(
217233 aesthetics ,
218234 name = " Week" ,
219235 breaks = date_yw_breaks(),
236+ labels = ggplot2 :: waiver(),
220237 limits = NULL ,
221238 position = " bottom"
222239){
@@ -227,6 +244,7 @@ scale_date_yw <- function(
227244 breaks = breaks ,
228245 palette = identity ,
229246 guide = " none" ,
247+ labels = labels ,
230248 trans = date_yw_trans ,
231249 super = ggplot2 :: ScaleContinuousDate ,
232250 position = position ,
@@ -407,9 +425,6 @@ date_yw_breaks <- function(
407425 breaks <- date_yw(seq(ywin , ywax , by = by ), 1 )
408426 }
409427
410- # fix breaks at the corner of the plot (outside the data range)
411- # this works well if the plot area is padded by 1 unit
412- # (see scale_date_** expand argument)
413428 breaks <- breaks [breaks > = xmin & breaks < = xmax ]
414429
415430 if (length(breaks ) == 1 ){
0 commit comments