[R] is there any option like cex.axis in ggplot2?

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Thu Mar 5 11:53:45 CET 2009


Dear Tom,

You can control the size of the axis title in ggplot2. It is described in the ggplot2 book. Have a look at Chapter 8: Polishing your plots for publication. You can find the book on the ggplot2 website.

I tend to create my own theme for some specific type of plots. Below you can find a theme for plots with rotated labels on the X-axis. Using such a theme is similar to adding an extra geom.

ggplot(dat, aes(x = factor(time), y = volume)) + geom_boxplot() + geom_jitter(aes(colour = id)) + labs(x = "time", y = volume) + BaseThemeX90()

BaseThemeX90 <- function(base_size = 10) {
	structure(list(
					axis.line =         theme_blank(),
					axis.text.x =       theme_text(size = base_size * 0.8 , lineheight = 0.9, colour = "grey50", hjust = 1, angle = 90),
					axis.text.y =       theme_text(size = base_size * 0.8, lineheight = 0.9, colour = "grey50", hjust = 1),
					axis.ticks =        theme_segment(colour = "grey50"),
					axis.title.x =      theme_text(size = base_size),
					axis.title.y =      theme_text(size = base_size, angle = 90),
					axis.ticks.length = unit(0.15, "cm"),
					axis.ticks.margin = unit(0.1, "cm"),
					
					legend.background = theme_rect(colour=NA), 
					legend.key =        theme_rect(fill = "grey95", colour = "white"),
					legend.key.size =   unit(1.2, "lines"),
					legend.text =       theme_text(size = base_size * 0.7),
					legend.title =      theme_text(size = base_size * 0.8, face = "bold", hjust = 0),
					legend.position =   "right",
					
					panel.background =  theme_rect(fill = "grey90", colour = NA), 
					panel.border =      theme_blank(), 
					panel.grid.major =  theme_line(colour = "white"),
					panel.grid.minor =  theme_line(colour = "grey95", size = 0.25),
					panel.margin =      unit(0.25, "lines"),
					
					strip.background =  theme_rect(fill = "grey80", colour = NA), 
					strip.label =       function(variable, value) value, 
					strip.text.x =      theme_text(size = base_size * 0.8),
					strip.text.y =      theme_text(size = base_size * 0.8, angle = -90),
					
					plot.background =   theme_rect(colour = NA),
					plot.title =        theme_text(size = base_size * 1.2),
					plot.margin =       unit(c(1, 1, 0.5, 0.5), "lines")
			), class = "options")
}


HTH,

Thierry


----------------------------------------------------------------------------
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be 
www.inbo.be 

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Namens Tom Cohen
Verzonden: donderdag 5 maart 2009 10:13
Aan: r-help at r-project.org
Onderwerp: [R] is there any option like cex.axis in ggplot2?

Dear list, 
 
I made boxplots using ggplot and want to control for x- and yaxis. Using "plot" I can do it by setting cex.axis equally to any size but can't figure out how to do it with ggplot.
 
 
ggplot(dat, aes(x = factor(time), y = volume)) + opts(axis.title.x=theme_text(size=8),axis.title.y=theme_text(size=8)) +
geom_boxplot() + geom_jitter(aes(colour = id))+labs(x = "time", y = volume)
 
Thanks for your help,
 
Tom
 
 


      __________________________________________________________
Går det långsamt? Skaffa dig en snabbare bredbandsuppkoppling. 
Sök och jämför priser hos Kelkoo.
http://www.kelkoo.se/c-100015813-bredband.html?partnerId=96914325
	[[alternative HTML version deleted]]


Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.




More information about the R-help mailing list