Reputation: 710
df <- data.frame(value = c(1, 2, 1.5), bin = c('B', 'C', 'D'))
p <- ggplot(data = df, aes(x = df$bin, y = df$value, group = 1)) + geom_line() + geom_point()
I want an x tick for 'A' that has no value or line it it. I have other plots that do have a value for 'A' and I want to make all axes consistent.
I was hoping this would work, but it does not:
p + scale_x_discrete(breaks = c('A', 'B', 'C', 'D'))
Upvotes: 0
Views: 1057
Reputation: 7818
use this instead:
p + scale_x_discrete(limits = c('A', 'B', 'C', 'D'))
Also, it's better if you don't use df$
inside aes
.
Better this way:
p <- ggplot(data = df, aes(x = bin, y = value, group = 1)) +
geom_line() +
geom_point()
Upvotes: 1