Reputation: 7879
I am trying to coerce the ticks of the x-axis to be the individual characters in a character vector. How can this be accomplished?
I've tried:
char.list <- c('a','l','t','e','r','e','d')
times <- c(1:7)
df <- as.data.frame(list('chars'=char.list, 'times'=times))
g <- ggplot(data=df, aes(x=1:length(char.list), y=times)) +
scale_x_discrete("Characters",breaks=char.list,
labels=char.list) +
geom_point(aes(size=10, colour='red'))
When I try @Heroka's code, this results in:
Upvotes: 0
Views: 414
Reputation: 31452
ggplot(data=df, aes(x=1:length(char.list), y=times)) +
geom_point(aes(size=10, colour='red'))+
scale_x_continuous(breaks=1:length(char.list), labels=char.list)
produces
Upvotes: 3