Reputation: 93
I'd like to create a line graph with irregular break intervals on the x-axis. When I define the breaks as in the code example, I get additional unlabeled breaks, which always seem to be exactly in the middle of two defined breaks and thus are unregular too (see image in link).
test_frame <- data.frame("v1"=1:3,"v2"=3:1)
library(ggplot2)
ggplot(data = test_frame, aes(x=v1, y=v2, group=1))+geom_line()+
scale_x_continuous(breaks = c(2.74,2.43,1.19))
Graph with additional breaks:
Is there any way to get rid of these vertical lines, so that there are only lines at the defined break position? I'd be grateful for any suggestions.
Upvotes: 3
Views: 1750
Reputation: 33488
ggplot(data = test_frame, aes(x = v1, y = v2, group = 1)) +
geom_line() +
scale_x_continuous(breaks = c(2.74, 2.43, 1.19)) +
theme(panel.grid.minor = element_blank()) # or panel.grid.minor.x to keep horizontal lines
Upvotes: 3
Reputation: 84529
Set minor_breaks = NULL
:
scale_x_continuous(breaks = c(2.74,2.43,1.19), minor_breaks = NULL)
Upvotes: 4