[R] Plotting an interaction with error bars
Jim Lemon
jim at bitwrit.com.au
Wed Nov 4 06:41:59 CET 2009
On 11/03/2009 10:15 PM, Dror D Lev wrote:
> Hello.
>
> I need to plot a two-way interaction (5 levels X 3) with error bars.
> The x.factor will be the five-levels var and the trace.factor will be
> the three level var.
>
> I was able to find functions that draw error bars, but still couldn't
> find a way to draw an interaction plot that looks like what is common
> in psychological (and related) journals: the lines (three in my need)
> are plotted in parallel and to avoid overlapping of the error bars a
> small jitter is added.
>
> I was able to make plotmeans() {from gplots} draw the interaction but
> with the lines plotted side by side (not parallel), resulting in three
> panes of one line each. When I tried manually super-imposing (looping
> a draw of one line for each level in the trace.factor) I got the
> overall look, but the error bars overlap and are hard to distinguish.
>
> Another attempt I made was with ci.plot() {from pda}. Inputting an
> aov() model resulted in a perfect plot of interaction but which is
> very limited to handle - I was unable to add a legend, change symbols
> etc.
>
> Does anybody knows if there is a way to manipulate either of the above
> functions more then what I was able to?
> Is there another function to draw interaction plots with error bars?
>
>
Hi Dror,
I think you want to offset the points in a group along the x axis so
that the points and error bars don't overlap. Try introducing an x
offset of maybe 0.1 in your try with plotmeans. To see an example of
what this looks like and how it is done, have a look at brkdn.plot in
the plotrix package.
Jim
More information about the R-help
mailing list