scales
scales copied to clipboard
In label_date_short, can all days, months and years be lined up (regardless of the vjust selected)?
scale_date_short
would look better if all the date labels of the same level lined up.
So in the example below, the "Oct" and "Apr" labels would be in line with the "Jan" and "Jul" labels
This seems like an issue with the vjust
of the labels, which in ggplot2 you can change with + theme(axis.text.x.bottom = element_text(vjust = 1))
.
That cramps things too close to the axis line and ticks, and forces someone to choose a vjust that is different to what they might have wanted. I.e. they might want vjust of 0.5, but just all comparable label levels on the same line, so they are easy to read, and have nice symmetry
Sometimes you get situations like this...
![image](https://user-images.githubusercontent.com/55065152/171986896-68c22122-0537-4b7b-af5e-3aff2a3f7d33.png)
This function would be much improved if all days were able to line-up, all months able to line -up, and all years able to line-up
A way to do this would be to construct breaks so that empty lines are given "", such that all labels have the number of lines of the label with the most line seperators.
In the example above:
- the label that is "16" above, would instead be a string "16\n\n"
- the label above that is "06\nJune" would instead be "06\nJune\n"
etc.
This seems to have somehow got fixed, even though no code has been added to main??
library(tidyverse)
economics |>
filter(between(date, ymd("1990-01-01"), ymd("1990-03-01"))) |>
ggplot() +
geom_line(aes(date, unemploy)) +
scale_x_date(labels = scales::label_date_short())
Created on 2023-07-04 with reprex v2.0.2
Huh, interesting. I checked ggplot2 and stringi, but got no clue where this fix was applied :-)
Pretty weird, but great :) Closed the PR as well
Maybe it was grid or vctrs, or something else..