Change tick locations and labels in ggplot

Use the scale_x_continuous (or scale_y_continuous) to change tick locations and labels in ggplot.

Change the ticks:


p = ggplot(diamonds)+aes(x=carat,y=price) +
   scale_x_continuous(breaks=c(1,1.2,1.5,2.5))

Change the ticks and tick labels:

p = ggplot(diamonds)+aes(x=carat,y=price) +
   scale_x_continuous(breaks=c(1,1.2,1.5,2.5), labels=c('a','b','c','d'))

Tags: ,

Leave a Reply