[R] interaction.plot - gridlines and formatting legend title...

dwinsemius at comcast.net dwinsemius at comcast.net
Thu Feb 19 04:04:51 CET 2009


 -------------- Original message ----------------------
From: Dimitri Liakhovitski <ld7631 at gmail.com>
> Thank you for providing advice on this graphics question.
> 
> I am building an interaction.plot.
> 
> d=data.frame(xx=c(3,3,2,2,1,1),yy=c(4,3,4,3,4,3),zz=c(5.1,4.2,4.4,3.5,3.3,-1.1,-
> 1.3)

You have different length vectors which should have thrown an error if you tested this.

> d[[1]]<-as.factor(d[[1]])
> d[[2]]<-as.factor(d[[2]])
> print(d)
> interaction.plot(d$xx, d$yy, d$zz,
>    type="b", col=c("red","blue"), legend=F,
>    lty=c(1,2), lwd=2, pch=c(18,24),
>    xlab="X Label",
>    ylab="Y Label",
>    main="Chart Label")
> legend("bottomright", c("level 1","level
> 2"),bty="n",lty=c(1,2),lwd=2,pch=c(18,24),
> col=c("red","blue"), title="Legend Title",inset = .02)
> 
> I think it is not using lattice, does it? So, I was wondering if it is
> at all possible to:
> 
> 1. Create gridlines in an interaction.plot

?par   search for "grid"; read material regarding tck parameter

> 2. Define the font type of the legend title (e.g., regular vs. bold as
> in font=2)

?par     see material on family argument
Set the par(family =    ) after the plot but before the legend call

Also
demo(Hershey)

> 3. Put actual values (on Y) next to each point in the graph.

?text

> 
> Thank you so much for your advice!
> 
> 
> -- 
> Dimitri Liakhovitski
> MarketTools, Inc.
> Dimitri.Liakhovitski at markettools.com
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list