[R] Placing Text on ggplot2 graphics vs. xyplot

baptiste auguie baptiste.auguie at googlemail.com
Thu Jun 16 23:17:50 CEST 2011


Hi,

As far as I know secondary y-axis and multiple pages are not possible
in ggplot2 (there are workarounds for the latter in the ggplot2 list
archives). For the subtitle, you could implement it with grid.text and
grid viewports,

library(gridExtra)
library(ggplot2)

grid.arrange( qplot(1,1), sub = textGrob(expression("this is my subtitle"),
    gp = gpar(fontsize = 8, fontface = "plain")))

HTH,

baptiste

On 17 June 2011 09:04, Guy Jett <GJett at itsi.com> wrote:
> Greetings to the help mailing list.
> I am in the process of translating a large graphic from xyplot to ggplot2 (13 columns by about rows).
> I have been unsuccessful trying to understand how to place the following text strings after three days of:
> * Perusing  Wickham's "gg2plot" book;
> * Searching his site for gg2plot and qplot;
> * Reviewing the "man pages" for gg2plot;
> * Searching the R archives.
>
> Problems are:
> * Translate the xyplot statement
>   "xlab.top = c("long string",   gpar(fontsize = 10, fontface = "bold  x=0, y=-1, just = "left"))"
>   to add a secondary x-axis to the top of my plot.
>   (This may have something to do with "strip.text.x" but I just cannot make that work.  Trying
>      several alternatives I keep getting error messages related to "Error in grobName(grob, prefix) :
>      Invalid 'grob' argument", but "Error in grobName" didn't show up in searched of the archives.)
>
>
> * Translate the xyplot statement
>   "sub = c("not so long string, gpar(fontsize = 8, fontface = "plain",  x=0.05, y=1, just = "left"))
>   to add a "footer" to the plot.
>
>
> * Split the lattice over multiple pages (each pages having three rows each) as xyplot allows using
>   "layout = c(13,3)"
>   (noting the ggplot2 "layout", such as vplayout, seems useful only for multiple plots on one screen /
>      page rather than splitting a single plot over multiple pages.)
>   (I could also do this by brute force, if needed.)
>
> My thanks to all,
> Guy Jett, R.G.
> Project Geologist
> ITSI,  A Gilbane Company
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list