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? Thanks for any help or comment. dror
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
Indeed, that seems very convenient. Thanks for your work and for the help. dror ------------------------- On Wed, Nov 4, 2009 at 12:17 PM, Jim Lemon <jim at bitwrit.com.au> wrote:> On 11/04/2009 06:36 PM, Dror D Lev wrote: >> >> Thank you Jim. >> >> brkdn.plot() seems to be just the function I need. >> >> Still, I wonder if there are lists of labels of the different measures >> of central tendency (mct argument) and measures of dispersion (md)? >> >> > > Hi Dror, > With brkdn.plot (and several other functions in plotrix) you can use any > existing measure or even roll your own. The only limitation is that the > function has to return a numeric value and must accept an "na.rm" argument. > > Jim > >
Seemingly Similar Threads
- introducing jitter in overlapping graphs using ggplots (plotmeans). Also sciplot.
- How to plot 2 continous variables on double y-axis with 2 factors: ggplot2, gplot, lattice, sciplot?
- plot graph with error bars trouble
- Plotting power function to practice data
- Adjusting Yaxis (ylim) limits on a plotMeans(DV, IV1, IV2, error.bars="se")