Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Edited</strong> <code>opts</code> has been deprecated, replaced by <code>theme</code>; <code>element_blank</code> has replaced <code>theme_blank</code>; and <code>ggtitle()</code> is used in place of <code>opts(title = ...</code></p> <p>Sandy- thank you so much!!!! This does exactly what I want. I do wish we could control the clipping in geom.text or geom.annotate. </p> <p>I put together the following program if anybody else is interested.</p> <pre><code> rm(list = ls()) # clear objects graphics.off() # close graphics windows library(ggplot2) library(gridExtra) #create dummy data test= data.frame( group = c("Group 1", "Group 1", "Group 1","Group 2", "Group 2", "Group 2"), x = c(1 ,2,3,1,2,3 ), y = c(33,25,27,36,23,25), n=c(71,55,65,58,65,58), ypos=c(18,18,18,17,17,17) ) p1 &lt;- qplot(x=x, y=y, data=test, colour=group) + ylab("Mean change from baseline") + theme(plot.margin = unit(c(1,3,8,1), "lines")) + geom_line()+ scale_x_continuous("Visits", breaks=seq(-1,3) ) + theme(legend.position="bottom", legend.title=element_blank())+ ggtitle("Line plot") # Create the textGrobs for (ii in 1:nrow(test)) { #display numbers at each visit p1=p1+ annotation_custom(grob = textGrob(test$n[ii]), xmin = test$x[ii], xmax = test$x[ii], ymin = test$ypos[ii], ymax = test$ypos[ii]) #display group text if (ii %in% c(1,4)) #there is probably a better way { p1=p1+ annotation_custom(grob = textGrob(test$group[ii]), xmin = 0.85, xmax = 0.85, ymin = test$ypos[ii], ymax = test$ypos[ii]) } } # Code to override clipping gt &lt;- ggplot_gtable(ggplot_build(p1)) gt$layout$clip[gt$layout$name=="panel"] &lt;- "off" grid.draw(gt) </code></pre> <p><img src="https://i.stack.imgur.com/gxfcj.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload