shosaco / vistime

Pretty timelines in R.
https://shosaco.github.io/vistime
GNU General Public License v3.0
168 stars 11 forks source link

x-axis dates not aligned properly #16

Closed maxeyre closed 1 year ago

maxeyre commented 4 years ago

Hi,

I'm not sure why but the x-axis years aren't aligned properly when I use your package - it starts on 2013-01-01 and ends on 2021-01-01. Code I am using is gg_vistime(data, optimize_y = TRUE, linewidth = 30)

Any ideas why this is or how I can change it?

Screenshot 2020-06-08 at 17 32 49

shosaco commented 4 years ago

Hi Max,

please send me a reproducible example so that I can see what is expected and where the labels should be - thanks!

maxeyre commented 4 years ago

Hi, actually just figured it out! The issue was actually just that the number of lines it automatically gave didn't line up as six-months or yearly, so lines were out of place not years.

The below (borrowed from your other issue) solved it, using the number of lines required to give it 6-monthly axis ticks:

gg_vistime(data, optimize_y = TRUE, linewidth = 30, background_lines = 16) + 
    scale_x_datetime(breaks = seq(min(as.POSIXct(data$start)),
                                  max(as.POSIXct(data$end)),
                                  "year"),
                     date_labels = "%Y") + 
     xlab("Year")

Screenshot 2020-06-08 at 17 54 17

Thanks very much for your package by the way, very useful. One other question, is there any way to reduce the height of each group or spacing between each column?