Axis Attributes - janeshdev/ggplot2 GitHub Wiki

Axis Attributes

Return to opts() list

Base Plot

#create simple dataframe for plotting
xy <- data.frame(x=1:10, y=10:1)

#create base plot
plot <- ggplot(data = xy)+
geom_point(aes(x = x, y = y))

#plot base plot
plot

http://imgur.com/7y9Dr.png

axis.text.x (text)

#color doesn't work, need colour
plot + theme(axis.text.x = element_text(colour = 'red', angle = 45, size = 10, hjust = -3, vjust = 7, face = 'italic'))

http://imgur.com/uwldX.png

axis.text.y (text)

#color doesn't work, need colour
plot + theme(axis.text.y = element_text(colour = 'red', angle = 45, size = 10, hjust = -3, vjust = 7, face = 'italic'))

http://imgur.com/4PIdH.png

axis.title.x (text)

#color doesn't work, need colour
plot + theme(axis.title.x = element_text(colour = 'red', angle = 45, size = 10, hjust = 0.5, vjust = 0, face = 'italic'))

http://imgur.com/nOiwb.png

axis.title.y (text)

#color doesn't work, need colour
plot + theme(axis.title.y = element_text(colour = 'red', angle = 45, size = 10, hjust = -0.2, vjust = 0.5, face = 'italic'))

http://imgur.com/olMTJ.png

axis.line (line)

#color doesn't work, need colour
plot + theme(axis.line = element_line(colour = 'red', size = 3, linetype = 'dashed'))

http://imgur.com/12WWu.png

axis.ticks (line)

#color doesn't work, need colour
plot + theme(axis.ticks = element_line(colour = 'red', size = 3, linetype = 'dashed'))

http://imgur.com/fwBAV.png

axis.ticks.length (unit)

#requires importing 'grid' package
plot + theme(axis.ticks.length = unit(1, "cm"))

http://imgur.com/S4d4P.png

axis.ticks.margin (unit)

#requires importing 'grid' package
plot + theme(axis.ticks.margin = unit(1, "cm")) 

http://imgur.com/R6LLB.png