On Wednesday 02 March 2005 09:29, Bock, Michael wrote:> I am trying to get the same text printed on each page of a multi-page
> series of bar charts. The text need to appear in the upper left-hand
> corner of the page, outside of the plot area. A watermark might be
> the closest analogy to what I am after
>
> This is what I have so far:
>
> PData <- na.omit(subset(TData,Matrix == "Product"))
> barchart(AdjResND0 ~ reorder(Compound, Sort) | Label , PData,
> box.ratio = 0.8, ylab= ("Concentration (mg/kg)"),
> layout = c(0,1), scales =
list(x="free",y="free",rot=90,cex = 0.4,
> axs = "i" ), panel=function(x,y,...) {
> panel.barchart(x,y,...)
> grid.text(label = "Privileged and Confidential \nDRAFT",
> x = unit(0.01, "npc"), y = unit(0.95, "npc"))})
>
>
> This plot a bar chart for each sample, with label representing the
> sample ID. I love getting 30 plots with a small among of code! The
> problem with this is that the text appears inside the plot area, I
> need it outside in the corner of the page.
>
> I think I am close, perhaps if I have the text be in the primary
> panel which would be taking up the whole page with the bar chart
> inside in a sub panel? An example would be great as I have tried a
> number of things and I either get errors or "curious" looking
plots.
> The option of last resort would be to explicitly plot each sample and
> add the text to each plot, but this does not take advantage of the
> multi-plot capabilities of lattice graphics.
If I'm not mistaken, you want (conceptually) a label for every page, not
every panel (in your case you have one panel per page, so the
distinction is not as obvious). The correct way to do this would be
through the 'page' argument, not the panel function. e.g.,
barchart(variety ~ yield | site, data = barley,
groups = year, layout = c(3,1),
page = function(n) {
grid.text(label = "Privileged and Confidential \nDRAFT",
x = unit(0.01, "npc"), y = unit(0.95,
"npc"),
just = c("left", "center"))
})
HTH,
Deepayan