Archive for the ‘R’ Category

Change axis labels in ggplot

Sunday, January 13th, 2008

By default, ggplot uses the variable name as the axis labels. Change it to something else using scale_x_continuous or scale_y_continuous


p = ggplot(diamonds)+geom_point()+aes(x=carat,y=price)

p + scale_x_continuous('x axis label') + scale_y_continuous('y axis label')