I posted my original question yesterday which got solved perfectly here
Original post
I made a few addition to my code
library(lubridate)
li
ggplot2
doesn't make this easy. Below is one-way to approach this interactively. Basically, you just grab the relevant part of the plot (the axis line and ticks) and reposition them.
If p
is your plot
p
grid.force()
# grab the relevant parts - have a look at grid.ls()
tck <- grid.gget("axis.1-1-1-1", grep=T)[[2]] # tick marks
ax <- grid.gget("axis.line.x", grep=T) # x-axis line
# add them to the plot, this time suppressing the x-axis at its default position
p + lapply(list(ax, tck), annotation_custom, ymax=0) +
theme(axis.line.x=element_blank(),
axis.ticks.x=element_blank())
Which produces
A quick note: the more recent versions of ggplot2
have the design decision to not show the axis. Also changes to axis.line
are not automatically passed down to the x
and y
axis. Therefore, I tweaked your theme to define axis.line.x
and axis.line.y
separately.
That siad, perhaps its easier (and more robust??) to use geom_hline
as suggested in the comments, and geom_segment
for the ticks.