[R] ggplo2: x_discrete labels size/direction

Xavier Chardon xavier.chardon at rennes.inra.fr
Tue May 6 10:02:06 CEST 2008


Hi Mikhail,

You can reduce the text size using the "grid.gedit" approach described 
at the end of the ggplot book, available on Hadley Wickham's website:
http://had.co.nz/ggplot2/book.pdf

You could use something like:
grid.gedit(gPath("xaxis", "labels"), gp=gpar(fontsize=6))

I'm not aware of a good way of rotating the text. I tried it but it did 
not look good, because with grid.gedit, the position of the different 
elements is not adjusted. So if you rotate labels, maybe they will be 
drawn on top of the axis title.

For the pdf device, you also need to specify the size of the graphic 
region, with something like:
pdf(paper="a4r", width=9, height=6)
see ?pdf for details

Xavier


Mikhail Spivakov a écrit :
> Hi everyone,
>
> I've got quite a few labels along the x axis and ggplot2 basically just
> crams them on top of each other.
> Is it possible to reduce the font size and/or text direction?
>
> Stretching the "windows" device window manually also helps, but I found that
> setting the parameters for the pdf device (where my scripts should print the
> data), such as paper="a4r" just results in a lot of empty space at both
> sides.
>
> Thanks for your help!
>
> Mikhail
>
> ====
> Mikhail Spivakov, PhD
> Postdoctoral Fellow
> EMBL/EBI
> UK & Germany
>   

-- 
Xavier Chardon
Thésard Institut de l'élevage / INRA
Projet ACTA "modélisation environnementale des systèmes bovins et porcins"

xavier.chardon at inst-elevage.asso.fr
xavier.chardon at rennes.inra.fr
02 23 48 50 91



More information about the R-help mailing list