I am guessing that you are trying to use the densityplot function from the
lattice package (if you had followed the posting guidelines and told us
which package you were using, then we would not need to guess).
If that is the case then you are trying to mix base graphics (mfrow) and
grid graphics (densityplot) and the 2 do not play nicely together (without
extra effort).
One option would be to use only base graphics and plot the pairs of
densities yourself using plot, lines, density, and maybe other functions.
Probably a little bit better is to use only lattice tools, see the help
page ?print.trellis and specifically the split and more arguments for how
to put multiple trellis plots onto a single page.
You could mix the 2 using the gridBase package, but that is probably way
more work than needed for this.
You could also investigate the ggplot2 package which may make this easier
using grid graphics.
On Thu, Jul 18, 2013 at 1:04 AM, meng <laomeng_3@163.com> wrote:
> Hi all:
> My data:
> f1 f2 f3 f4 y
> 1 -4.45 3 6.44 3.72 1
> 2 25.66 121 39.03 3.55 0
> 3 -9.75 12 11.77 3.40 1
> 4 -12.09 17 13.75 3.33 0
> 5 -3.53 4 6.47 3.24 0
> 6 13.18 69 26.55 3.20 1
> ... ...
> I want to plot f1 for y=0 and 1; f2 for y=0 and 1...and the same as f3,f4.
> And I want to get 4 plots at once(2*2)
>
> My code:
> par(mfrow=c(2,2))
> densityplot(~f1,data=dat,group=y,auto.key=T)
> densityplot(~f2,data=dat,group=y,auto.key=T)
> densityplot(~f3,data=dat,group=y,auto.key=T)
> densityplot(~f4,data=dat,group=y,auto.key=T)
>
> The result is not what I want,since it produce 1 plot a time,but not 4
> plots together(2*2).
> Maybe something wrong with par(mfrow=c(2,2))?
> Any suggestion? Many thanks!
>
> Best.
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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.
>
--
Gregory (Greg) L. Snow Ph.D.
538280@gmail.com
[[alternative HTML version deleted]]