I am trying to plot out data along a continuous date axis. I cannot figure out how to create a custom axis to suit my needs. the default plot()
function adds dates (2018
, 2019
, and 2020
) on the x axis, but I would like it broken down by year and month, so in plot I have added axes=F
.
My data is originally a character string in the format YYYY-mm-dd hh:mm:ss
. I've as.Date
it before attempting to graph using the plot() function.
plot(df$y ~ df$x, type = "n", xlab = "", ylab = "", axes=F)
box()
axis(2, at=seq(0,200,30))
axis(1, df2$x, format(df2$x, "%Y-%m"), "month"), seq(1,11000,(11000/24)))
This last line is where I am stuck. I have formatted it over to the format I would like, and it plots, but it plots all 11000~ x axis instances and leaves a thick black bar because there are so many ticks so close together. My data starts at 2018-01, and ends at 2019-11, how can I change this to only have 24 ticks? I think my issue lies in the fact that I do not know how to properly refer to these data values in the sequence section of the axis function.