[R] Automatic anchors for text boxes
ymoisan at groupesm.com
Fri Aug 31 15:20:38 CEST 2007
I'm struggling to add text automatically to plots. I have a series of
scatterplots that I have stored in a script because the underlying data
changes often and the plots need to be regenerated. I use the scatterplot
function (defined in Rcmd, I believe). When one of the variables is a
factor, a boxplot is drawn over the scatter of the other variable. In the
case where x is a factor with 10 values, I'll see 10 vertical boxplots. So
far, so good.
I was asked to show other stats on top of those scatterplots, e.g. mean,
number of observations, etc. I can find those values, but the problem is I
don't know how to put them on the plot, given I don't want to look at each
plot one by one and manually identify the locations where I need to add the
text. I was wondering if something like a pseudo label (I want to keep the
original axis labels) existed that could be used to anchor a text box ? Or
maybe a semi-manual approach where I could offset such a pseudo-label
position along the y axis? Since I know the size of my resulting jpegs, I
could use a constant y offset for the text and they'd be aligned properly
along the x axis because they are labels. For the mean value, I could draw
a short horizontal line segment across the boxplot, but again I'd have the
problem of tying that line segment to specific x-axis values so they
intersect the right boxplot. Any clues ?
On a related note, I've added regression lines, again by factor (thanks
scatterplot!), and was asked to write the regression equation in plain text.
I have between one and 7 lines on the plots, so again how could I
automatically tie a text box, this time to a specific regression line ?
Maybe that would be easier using a legend, but it would be nice to be able
to write the equation alongside the line.
View this message in context: http://www.nabble.com/Automatic-anchors-for-text-boxes-tf4360108.html#a12426263
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help