Is it possible to make every Nth tick on an axis bold using ggplot2? I only want to have the axis tick bold (the small line), not the text.
This would be useful for highlighting every 7th tick when showing daily data in a plot. I'd like to keep the tick marks for every day.
I haven't been able to find anything regarding this topic, any help would be appreciated!
EDIT: Here is a code example. I've extended it at the last line to increase the size of all ticks. What I'd like is to have every Nth label larger. For example every 7th. Defining every 7th one manually wouldn't work since I'm working with data that changes every day.
library(ggplot2)
library(lubridate)
theme_set(theme_bw())
df <- economics_long[economics_long$variable %in% c("psavert", "uempmed"), ]
df <- df[lubridate::year(df$date) %in% c(1967:1981), ]
# labels and breaks for X axis text
brks <- df$date[seq(1, length(df$date), 12)]
lbls <- lubridate::year(brks)
# plot
ggplot(df, aes(x=date)) +
geom_line(aes(y=value, col=variable)) +
labs(title="Time Series of Returns Percentage",
subtitle="Drawn from Long Data format",
caption="Source: Economics",
y="Returns %",
color=NULL) + # title and caption
scale_x_date(labels = lbls, breaks = brks) + # change to monthly ticks and labels
scale_color_manual(labels = c("psavert", "uempmed"),
values = c("psavert"="#00ba38", "uempmed"="#f8766d")) + # line color
theme(axis.text.x = element_text(angle = 90, vjust=0.5, size = 8), # rotate x axis text
panel.grid.minor = element_blank(),
axis.ticks.x = element_line(colour = "black", size = 2))
Solution: Thanks to @Jimbou!
Using axis.ticks.x = element_line(colour = "black", size = c(2, rep(1,6)))
leads to this. Perfect for daily Data!