Hi, I am having some hard time figuring how to access (and modify) the properties of an object created by ggplot. I found 'ggopts', but it only returns some of the properties. Say I want to get the x- and y-axis limits, the tickmark locations, legend current position, the legend box and background color and set them to new values. Are these properties easily accessible (and modifiable) from the object? Here is an example library(ggplot2) pobj <- ggplot(data = movies[1:300,], aes(x = year, y = length, size rating)) + geom_point() + opts(legend.position = c(0.2,0.9)) Regards, TL
Hi Tribo,> I found 'ggopts', but it only returns some of the properties. Say I > want to get the x- and y-axis limits, the tickmark locations, legend > current position, the legend box and background color and set them to > new values. > > Are these properties easily accessible (and modifiable) from the object?Some of them are: * the x and y axis limits are properties of the scales (e.g. + scale_x_continuous(limits=c(5, 10)) * the tickmark locations and labels are also properties of the scales (e.g. + scale_x_continuous(breaks=c(5, 10), labels=c("five","ten")) * the legend position is set by ggopt() Some of them aren't: * legend fill and outline colours can only be changed by modifying the underlying grid object - see the last chapter of the ggplot book to see how to do this. Hadley -- http://had.co.nz/
Reasonably Related Threads
- How to pack my stuff into a package (library, collection)?
- More elegant multiplication or division of a data frame with a vector
- Combining several mappings in ggplot2
- How to split a factor (unique identifier) into several others?
- Plotting series marked with a symbol on every nth data point, preferably in ggplot...