Skip to content

Axis Attributes

bhive01 edited this page Sep 30, 2010 · 12 revisions

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

axis.text.x (text)

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

axis.text.y (text)

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

axis.title.x (text)

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

axis.title.y (text)

#color doesn't work, need colour
plot + opts(axis.text.y = theme_text(colour = 'red', angle = 45, size = 10, hjust=1, vjust=1, face='bold'))

axis.line (segment)

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

axis.ticks (segment)

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

axis.ticks.length (unit)

plot + opts(axis.ticks.length = unit(1, "cm"))

axis.ticks.margin (unit)

plot + opts(axis.ticks.margin = unit(1, "cm"))

Note: The ggplot2 wiki is no longer maintained, please use the ggplot2 website instead!

Clone this wiki locally