-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Graph Panel Attributes
bhive01 edited this page Sep 23, 2010
·
16 revisions
#create simple dataframe for plotting
x <- 1:10
y <- 10:1
xy <- as.data.frame(cbind(x,y))
#create base plot
plot <- ggplot(data = xy)+
geom_point(aes(x = x, y = y))
#plot base plot
plot
#color doesn't work, need colour
plot + opts(panel.background = theme_rect(colour = 'purple', fill = 'pink', size = 3, linetype='dashed'))
#color doesn't work, need colour
plot + opts(panel.border = theme_rect(colour = 'purple', fill = 'pink', size = 3, linetype='dashed'))
plot + opts(panel.grid.minor = theme_line(colour = 'red', size = 3, linetype = 'dashed'))
plot + opts(panel.grid.major = theme_line(colour = 'red', size = 3, linetype = 'dashed'))
#for facets
plot + opts(panel.margin = unit(2, "cm"))
#color doesn't work, need colour
plot + opts(plot.background = theme_rect(colour = 'purple', fill = 'pink', size = 3, linetype='dashed'))
#Give the plot a title first
plot + opts(title = 'Graph Title')
# Play with title appearance
plot + opts(title = 'Graph Title', plot.title = theme_text(colour = 'red', angle = 45, size = 10,hjust = 0.5, vjust = 0.5, face = 'bold'))
#creates white space around plot (Must define all 4 sides in vector)
plot + opts(plot.margin = unit(c(5, 5, 5, 5), "cm"))