Re: [R] multiple graphs on one plot

2019-05-14 Thread Andrew Halford
Hi Jim,

Many thanks for your help and yes CW is carapace width. Here is the final
coding I used...I set the peak of the curves at max frequency bin for each
sex. I also added the means and SD's from my data. According to my visual
diagnostics (qqplots, density plots) the frequency distributions do appear
normally distributed in this case. To be honest Ive struggled to find
whether CW is normally distributed in mud crab populations or not.


f<- lf_crabs$cw[lf_crabs$sex=='female']
m<- lf_crabs$cw[lf_crabs$sex=='male']

# find mean and sd to determine normal curve dimensions
m_m <-mean(m)
sd_m <-sqrt(var(m))
m_f <-mean(f)
sd_f <-sqrt(varf(f))

mf <- list(f,m)
multhist(mf, xlab="CW", ylab="Frequency", ylim=c(0,100),main="All Measured
Crabs", col=c("dark gray", "light gray"),
 breaks=seq(90,210, by=10),beside=TRUE,space=c(0,0.5))
legend("topright", c("Females", "Males"), fill=c("dark gray", "light gray"))
lines(seq(0,32,length.out=121),rescale(dnorm(90:210,145.4867,20.99906),c(0,50)),col="dark
gray",lwd=2)
lines(seq(0,32,length.out=121),rescale(dnorm(90:210,151.0783,21.88299),c(0,80)),col="light
gray",lwd=2)
abline(v=145.4867,lwd=2,col="red")

On Mon, 13 May 2019 at 17:30, Jim Lemon  wrote:

> Hi Andrew,
> First, a little mind reading. My crystal ball says that "cw" can be
> interpreted as "carapace width". It didn't tell me the parameters of
> the distribution, so:
>
> set.seed(1234)
> mf<-list(rnorm(400,145,15),rnorm(400,160,15))
> library(plotrix)
> multhist(mf, xlab="CW", ylab="Frequency", ylim=c(0,100),main="All Measured
> Crabs", col=c("dark gray", "light gray"),
>  breaks=seq(90,210, by=10),beside=TRUE,space=c(0,0.5))
> legend("topright", c("Females", "Males"), fill=c("dark gray", "light
> gray"))
> lines(seq(0,32,length.out=121),rescale(dnorm(90:210,145,15),c(0,100)))
>
> This produces what I think you are after. Note that it may be
> misleading as the distribution of carapace width in real mud crabs
> doesn't look normal to me.
>
> Jim
>
> On Mon, May 13, 2019 at 3:00 PM Andrew Halford 
> wrote:
> >
> > Hi Listers
> >
> > I've been trying to make a single graphic that has frequency histograms
> for
> > male and female mud crabs displayed side by side (such as when using the
> > beside=TRUE command for barplots). I then want to display a normal
> > distribution on top of the male and female histograms.
> >
> > I have been using the multhist command in Plotrix to generate the
> > histograms without too much problem, but I cannot get the normal
> > distributions to plot up on the same graph.
> >
> > Histograms plot
> >
> > mf <-
> >
> list(lf_crabs$cw[lf_crabs$sex=='female'],lf_crabs$cw[lf_crabs$sex=='male'])
> > multhist(mf, xlab="CW", ylab="Frequency", ylim=c(0,100),main="All
> Measured
> > Crabs", col=c("dark gray", "light gray"),
> >  breaks=seq(90,210, by=10),beside=TRUE,space=c(0,0.5))
> > legend("topright", c("Females", "Males"), fill=c("dark gray", "light
> gray"))
> >
> > Then I try to add a normal distribution curve just to the female data
> but I
> > cant get the output to plot
> >
> > points(seq(min(mf[[1]]), max(mf[[1]]), length.out=300),
> >dnorm(seq(min(mf[[1]]), max(mf[[1]]), length.out=300),
> >  mean(mf[[1]]), sd(mf[[1]])),type="l", col="dark gray")
> >
> > Even trying to add an abline to the plot doesn't work.
> >
> > What am I missing?
> >
> > cheers
> >
> > Andy
> >
> > --
> > Andrew Halford Ph.D
> > Senior Coastal Fisheries Scientist
> > Pacific Community | Communauté du Pacifique CPS – B.P. D5 | 98848 Noumea,
> > New Caledonia | Nouméa, Nouvelle-Calédonie
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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.
>


-- 
Andrew Halford Ph.D
Senior Coastal Fisheries Scientist
Pacific Community | Communauté du Pacifique CPS – B.P. D5 | 98848 Noumea,
New Caledonia | Nouméa, Nouvelle-Calédonie

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] multiple graphs on one plot

2019-05-13 Thread Jim Lemon
Hi Andrew,
First, a little mind reading. My crystal ball says that "cw" can be
interpreted as "carapace width". It didn't tell me the parameters of
the distribution, so:

set.seed(1234)
mf<-list(rnorm(400,145,15),rnorm(400,160,15))
library(plotrix)
multhist(mf, xlab="CW", ylab="Frequency", ylim=c(0,100),main="All Measured
Crabs", col=c("dark gray", "light gray"),
 breaks=seq(90,210, by=10),beside=TRUE,space=c(0,0.5))
legend("topright", c("Females", "Males"), fill=c("dark gray", "light gray"))
lines(seq(0,32,length.out=121),rescale(dnorm(90:210,145,15),c(0,100)))

This produces what I think you are after. Note that it may be
misleading as the distribution of carapace width in real mud crabs
doesn't look normal to me.

Jim

On Mon, May 13, 2019 at 3:00 PM Andrew Halford  wrote:
>
> Hi Listers
>
> I've been trying to make a single graphic that has frequency histograms for
> male and female mud crabs displayed side by side (such as when using the
> beside=TRUE command for barplots). I then want to display a normal
> distribution on top of the male and female histograms.
>
> I have been using the multhist command in Plotrix to generate the
> histograms without too much problem, but I cannot get the normal
> distributions to plot up on the same graph.
>
> Histograms plot
>
> mf <-
> list(lf_crabs$cw[lf_crabs$sex=='female'],lf_crabs$cw[lf_crabs$sex=='male'])
> multhist(mf, xlab="CW", ylab="Frequency", ylim=c(0,100),main="All Measured
> Crabs", col=c("dark gray", "light gray"),
>  breaks=seq(90,210, by=10),beside=TRUE,space=c(0,0.5))
> legend("topright", c("Females", "Males"), fill=c("dark gray", "light gray"))
>
> Then I try to add a normal distribution curve just to the female data but I
> cant get the output to plot
>
> points(seq(min(mf[[1]]), max(mf[[1]]), length.out=300),
>dnorm(seq(min(mf[[1]]), max(mf[[1]]), length.out=300),
>  mean(mf[[1]]), sd(mf[[1]])),type="l", col="dark gray")
>
> Even trying to add an abline to the plot doesn't work.
>
> What am I missing?
>
> cheers
>
> Andy
>
> --
> Andrew Halford Ph.D
> Senior Coastal Fisheries Scientist
> Pacific Community | Communauté du Pacifique CPS – B.P. D5 | 98848 Noumea,
> New Caledonia | Nouméa, Nouvelle-Calédonie
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] multiple graphs with a single legend and trellis graph

2015-07-08 Thread Jim Lemon
Hi Rosa,
As you are using base graphics, here is an example that might be of
use. As we don't have access to your data, I have used something
similar to the toy data in the example for the panes function. This
could be done better using the split.screen function, so let me know
if you would like an example using that.

 library(plotrix)
 # start a wide plotting device
 x11(width=10,height=4)
 y-runif(100)
 oldpar-panes(matrix(1:6,nrow=2,byrow=TRUE),widths=c(1,1,1.7))
 par(mar=c(0,2,1.8,0))
 boxplot(y,axes=FALSE)
 axis(2)
 box()
 par(mar=c(0,0,1.8,0))
 tab.title(Boxplot of y,tab.col=#88dd88,cex=1)
 y_hist-hist(y,axes=FALSE,breaks=seq(0,1,length.out=5))
 box()
 tab.title(Histogram of y,tab.col=#dd8800,cex=1)
 par(mar=c(0,0,1.8,12))
 pie(y_hist$counts,col=2:9)
 tab.title(Pie chart of y categories,tab.col=#dd,cex=1)
 box()
 par(mar=c(2,2,1.8,0))
 plot(y,xaxs=i,xlim=c(0,101),axes=FALSE,col=2:9)
 axis(2)
 box()
 tab.title(Scatterplot of y,tab.col=#aabbcc,cex=1)
 par(mar=c(2,0,1.8,0))
 plot(sort(y),xaxs=i,xlim=c(0,101),axes=FALSE,col=2:9)
 box()
 tab.title(Scatterplot of y sorted,tab.col=#ddbc44,cex=1)
 # center the title at the middle of the fifth plot
 mtext(Overall title of plot,side=1,line=0.8,cex=1.5)
 par(mar=c(2,0,1.8,12))
 plot(diff(y),xaxs=i,xlim=c(0,100),axes=FALSE,col=2:9)
 axis(4)
 box()
 tab.title(Scatterplot of diff(y),tab.col=#ff33cc,cex=1)
 legend(115,1.8,
  c(Boxplot,Histogram,Pie chart,Scatterplot,Sort,Diff),
  fill=c(#88dd88,#dd8800,#dd,#aabbcc,#ddbc44,#ff33cc),
  xpd=NA)

Jim




On Wed, Jul 8, 2015 at 1:05 PM, David Winsemius dwinsem...@comcast.net wrote:

 On Jul 7, 2015, at 2:45 PM, Rosa Oliveira wrote:

 Iam trying to plot 6 graphs in one single plot and I was able to, 
 nonetheless I wanted that all graphs had just 1 common legend, as the legend 
 is the same for all the 6 graphs and there is no sense in repeating it 6 
 times and even more, the legends in each graph sometimes don’t fit the graph.

 Is there a way to put just one legend for all the 6 graphs ate the same time?

 I was told to use a trellis graph, but after days of trying to do that I 
 wasn’t able to.

 Can anyone help me?


 library(ggplot2)
 library(reshape)


 library(lattice)

 Why did you load those packages above? As far as I can see you did not use 
 any lattice or ggplot2 functions. (Also see no reshape or reshape2 functions 
 in use.)

 par(mfrow=c(2,3))
 mse.alpha1 -read.csv(file=graphs_mse_alpha1.csv,head=TRUE,sep=,)

 And there you lose us. We are unable to see your data. The `legend` function 
 can put the legend anywhere. You may need to set par(xpd=TRUE) if the 
 location is outside the current plot area. If you wnated just one legend then 
 you mus ask yourself why you are issuing multiple legend calls. I see the 
 token-`legend` a total of 12 times in the code below.


 attach(mse.alpha1)
 names(mse1000.alpha1)
 mse.alpha2 -read.csv(file=graphs_mse_alpha2.csv,head=TRUE,sep=,)
 attach(mse.alpha2)
 names(mse.alpha2)
 nsample==50

 plot(mse.alpha1$lambda[mse.alpha1$nsample==50],
 mse.alpha1$mse.naive[mse.alpha1$nsample==50],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4,
 xlim=c(.6,1), ylim=c(0,1), cex.lab=1.5
 )
 lines(mse.alpha1$lambda[mse.alpha1$nsample==50],mse.alpha1$mse.RegCal[mse.alpha1$nsample==50],col=2,lty=2)
 lines(mse.alpha1$lambda[mse.alpha1$nsample==50],mse.alpha1$mse.PL[mse.alpha1$nsample==50],col=3,lty=3)
 title ( expression (paste (Mean squared error for , alpha[1])), 
 cex.main=1.5)
 title(\n\n sample size=50)
 legend(.7,1, legend= c(Naive, Regression Calibration, Pseudo 
 Likelihood), bty = n,col=c(4,2,3),lty=c(4,2,3))

 plot(mse.alpha1$lambda[mse.alpha1$nsample==250],
 mse.alpha1$mse.naive[mse.alpha1$nsample==250],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4,
 xlim=c(.6,1), ylim=c(0,1), cex.lab=1.5
 )
 lines(mse.alpha1$lambda[mse.alpha1$nsample==250],mse.alpha1$mse.RegCal[mse.alpha1$nsample==250],col=2,lty=2)
 lines(mse.alpha1$lambda[mse.alpha1$nsample==250],mse.alpha1$mse.PL[mse.alpha1$nsample==250],col=3,lty=3)
 title ( expression (paste (Mean squared error for , alpha[1])), 
 cex.main=1.5)
 title(\n\n sample size=250)
 legend(.7,1, legend= c(Naive, Regression Calibration, Pseudo 
 Likelihood), bty = n,col=c(4,2,3),lty=c(4,2,3))


 plot(mse.alpha1$lambda[mse.alpha1$nsample==1000],
 mse.alpha1$mse.naive[mse.alpha1$nsample== 1000],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4,
 xlim=c(.6,1), ylim=c(0,1), cex.lab=1.5
 )
 lines(mse.alpha1$lambda[mse.alpha1$nsample== 
 1000],mse.alpha1$mse.RegCal[mse.alpha1$nsample== 1000],col=2,lty=2)
 lines(mse.alpha1$lambda[mse.alpha1$nsample== 
 1000],mse.alpha1$mse.PL[mse.alpha1$nsample== 1000],col=3,lty=3)
 title ( expression (paste (Mean squared error for , alpha[1])), 
 cex.main=1.5)
 title(\n\n sample size=1000)
 legend(.7,1, legend= c(Naive, Regression Calibration, Pseudo 
 Likelihood), bty = n,col=c(4,2,3),lty=c(4,2,3))

 plot(mse.alpha2$lambda[mse.alpha2$nsample==50],
 

Re: [R] multiple graphs with a single legend and trellis graph

2015-07-08 Thread Rosa Oliveira
Dear Jim,

first of all, thank you very much :) 


can you please explain me how to use split.screen?

I’m felling so silly, I could not run your example because of 
x11(width=10,height=4). I already installed package XQuartz because X11 library 
was missing , nonetheless, after I have installed it, “ Error in 
.External2(C_X11, d$display, d$width, d$height, d$pointsize,  : 
  unable to start device X11
In addition: Warning message:
In x11(width = 10, height = 4) :
  unable to open connection to X11 display ‘' 


I didn’t started the x11 server on my mac ;) 

Now I got the graphs ;)

I attach my previous graphs and my data, so you can see :)









I’m very naive and new in R :(

Thanks again for your help ;)

Atenciosamente,
Rosa Oliveira
Atenciosamente,
Rosa Oliveira

-- 



Rosa Celeste dos Santos Oliveira, 

E-mail: rosit...@gmail.com
Tlm: +351 939355143 
Linkedin: https://pt.linkedin.com/in/rosacsoliveira

Many admire, few know
Hippocrates

 On 08 Jul 2015, at 11:20, Jim Lemon drjimle...@gmail.com wrote:
 
 Hi Rosa,
 As you are using base graphics, here is an example that might be of
 use. As we don't have access to your data, I have used something
 similar to the toy data in the example for the panes function. This
 could be done better using the split.screen function, so let me know
 if you would like an example using that.
 
 library(plotrix)
 # start a wide plotting device
 x11(width=10,height=4)
 y-runif(100)
 oldpar-panes(matrix(1:6,nrow=2,byrow=TRUE),widths=c(1,1,1.7))
 par(mar=c(0,2,1.8,0))
 boxplot(y,axes=FALSE)
 axis(2)
 box()
 par(mar=c(0,0,1.8,0))
 tab.title(Boxplot of y,tab.col=#88dd88,cex=1)
 y_hist-hist(y,axes=FALSE,breaks=seq(0,1,length.out=5))
 box()
 tab.title(Histogram of y,tab.col=#dd8800,cex=1)
 par(mar=c(0,0,1.8,12))
 pie(y_hist$counts,col=2:9)
 tab.title(Pie chart of y categories,tab.col=#dd,cex=1)
 box()
 par(mar=c(2,2,1.8,0))
 plot(y,xaxs=i,xlim=c(0,101),axes=FALSE,col=2:9)
 axis(2)
 box()
 tab.title(Scatterplot of y,tab.col=#aabbcc,cex=1)
 par(mar=c(2,0,1.8,0))
 plot(sort(y),xaxs=i,xlim=c(0,101),axes=FALSE,col=2:9)
 box()
 tab.title(Scatterplot of y sorted,tab.col=#ddbc44,cex=1)
 # center the title at the middle of the fifth plot
 mtext(Overall title of plot,side=1,line=0.8,cex=1.5)
 par(mar=c(2,0,1.8,12))
 plot(diff(y),xaxs=i,xlim=c(0,100),axes=FALSE,col=2:9)
 axis(4)
 box()
 tab.title(Scatterplot of diff(y),tab.col=#ff33cc,cex=1)
 legend(115,1.8,
  c(Boxplot,Histogram,Pie chart,Scatterplot,Sort,Diff),
  fill=c(#88dd88,#dd8800,#dd,#aabbcc,#ddbc44,#ff33cc),
  xpd=NA)
 
 Jim
 
 
 
 
 On Wed, Jul 8, 2015 at 1:05 PM, David Winsemius dwinsem...@comcast.net 
 wrote:
 
 On Jul 7, 2015, at 2:45 PM, Rosa Oliveira wrote:
 
 Iam trying to plot 6 graphs in one single plot and I was able to, 
 nonetheless I wanted that all graphs had just 1 common legend, as the 
 legend is the same for all the 6 graphs and there is no sense in repeating 
 it 6 times and even more, the legends in each graph sometimes don’t fit the 
 graph.
 
 Is there a way to put just one legend for all the 6 graphs ate the same 
 time?
 
 I was told to use a trellis graph, but after days of trying to do that I 
 wasn’t able to.
 
 Can anyone help me?
 
 
 library(ggplot2)
 library(reshape)
 
 
 library(lattice)
 
 Why did you load those packages above? As far as I can see you did not use 
 any lattice or ggplot2 functions. (Also see no reshape or reshape2 functions 
 in use.)
 
 par(mfrow=c(2,3))
 mse.alpha1 -read.csv(file=graphs_mse_alpha1.csv,head=TRUE,sep=,)
 
 And there you lose us. We are unable to see your data. The `legend` function 
 can put the legend anywhere. You may need to set par(xpd=TRUE) if the 
 location is outside the current plot area. If you wnated just one legend 
 then you mus ask yourself why you are issuing multiple legend calls. I see 
 the token-`legend` a total of 12 times in the code below.
 
 
 attach(mse.alpha1)
 names(mse1000.alpha1)
 mse.alpha2 -read.csv(file=graphs_mse_alpha2.csv,head=TRUE,sep=,)
 attach(mse.alpha2)
 names(mse.alpha2)
 nsample==50
 
 plot(mse.alpha1$lambda[mse.alpha1$nsample==50],
 mse.alpha1$mse.naive[mse.alpha1$nsample==50],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4,
 xlim=c(.6,1), ylim=c(0,1), cex.lab=1.5
 )
 lines(mse.alpha1$lambda[mse.alpha1$nsample==50],mse.alpha1$mse.RegCal[mse.alpha1$nsample==50],col=2,lty=2)
 lines(mse.alpha1$lambda[mse.alpha1$nsample==50],mse.alpha1$mse.PL[mse.alpha1$nsample==50],col=3,lty=3)
 title ( expression (paste (Mean squared error for , alpha[1])), 
 cex.main=1.5)
 title(\n\n sample size=50)
 legend(.7,1, legend= c(Naive, Regression Calibration, Pseudo 
 Likelihood), bty = n,col=c(4,2,3),lty=c(4,2,3))
 
 plot(mse.alpha1$lambda[mse.alpha1$nsample==250],
 mse.alpha1$mse.naive[mse.alpha1$nsample==250],
 

Re: [R] multiple graphs with a single legend and trellis graph

2015-07-08 Thread Rosa Oliveira
Dear Jim,

first of all, thank you very much :) 


can you please explain me how to use split.screen?


I attach my previous graphs and my data, so you can see :)









I’m very naive and new in R :(

I really tried:

library(plotrix)
# start a wide plotting device
x11(width=10,height=4)
y-runif(100)
oldpar-panes(matrix(1:6,nrow=2,byrow=TRUE),widths=c(1,1,1.7))
par(mar=c(0,2,1.8,0))

mse - plot(mse.alpha1$lambda[mse.alpha1$nsample==50],
 mse.alpha1$mse.naive[mse.alpha1$nsample==50],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,1), cex.lab=1.5
 #,main=yaxs default
)
lines(mse.alpha1$lambda[mse.alpha1$nsample==50],mse.alpha1$mse.RegCal[mse.alpha1$nsample==50],col=2,lty=2)
lines(mse.alpha1$lambda[mse.alpha1$nsample==50],mse.alpha1$mse.PL[mse.alpha1$nsample==50],col=3,lty=3)
tab.title(alpha 1 N sample=50,tab.col=#88dd88,cex=1)
# tab.title(\n\n sample size=50)
# problem: when I run: tab.title(Mean squared error for , 
paste(alpha[1])),tab.col=#88dd88,cex=1)
# I get an error message: unexpected string constant in tab.title(Mean 
squared error for , paste(alpha[1])),tab.col=
# I searched but wasn't able to fix this one, neither the other subtitle:
# tab.title(\n\n sample size=50)
box()


par(mar=c(0,0,1.8,0))
plot(mse.alpha1$lambda[mse.alpha1$nsample==250],
 mse.alpha1$mse.naive[mse.alpha1$nsample==250],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,1), cex.lab=1.5
 #,main=yaxs default
)
lines(mse.alpha1$lambda[mse.alpha1$nsample==250],mse.alpha1$mse.RegCal[mse.alpha1$nsample==250],col=2,lty=2)
lines(mse.alpha1$lambda[mse.alpha1$nsample==250],mse.alpha1$mse.PL[mse.alpha1$nsample==250],col=3,lty=3)
tab.title ( alpha 1 N sample=250,tab.col=#dd8800,cex=1)
box()


plot(mse.alpha1$lambda[mse.alpha1$nsample==1000],
 mse.alpha1$mse.naive[mse.alpha1$nsample== 1000],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,1), cex.lab=1.5
 #,main=yaxs default
)
lines(mse.alpha1$lambda[mse.alpha1$nsample== 
1000],mse.alpha1$mse.RegCal[mse.alpha1$nsample== 1000],col=2,lty=2)
lines(mse.alpha1$lambda[mse.alpha1$nsample== 
1000],mse.alpha1$mse.PL[mse.alpha1$nsample== 1000],col=3,lty=3)
tab.title(alpha 1 N sample=1000,tab.col=#dd,cex=1)
box()



par(mar=c(2,2,1.8,0))
plot(mse.alpha2$lambda[mse.alpha2$nsample==50],
 mse.alpha2$mse.naive[mse.alpha2$nsample==50],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,.17), cex.lab=1.5
 #,main=yaxs default
)
lines(mse.alpha2$lambda[mse.alpha2$nsample==50],mse.alpha2$mse.RegCal[mse.alpha2$nsample==50],col=2,lty=2)
lines(mse.alpha2$lambda[mse.alpha2$nsample==50],mse.alpha2$mse.PL[mse.alpha2$nsample==50],col=3,lty=3)
box()
tab.title(alpha 2 N sample=50,tab.col=#aabbcc,cex=1)

par(mar=c(2,0,1.8,0))
plot(mse.alpha2$lambda[mse.alpha2$nsample==250],
 mse.alpha2$mse.naive[mse.alpha2$nsample==250],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,.17), cex.lab=1.5
 #,main=yaxs default
)
lines(mse.alpha2$lambda[mse.alpha2$nsample==250],mse.alpha2$mse.RegCal[mse.alpha2$nsample==250],col=2,lty=2)
lines(mse.alpha2$lambda[mse.alpha2$nsample==250],mse.alpha2$mse.PL[mse.alpha2$nsample==250],col=3,lty=3)
box()
tab.title(alpha 2 N sample=250,tab.col=#ddbc44,cex=1)


# center the title at the middle of the fifth plot
mtext(Mean Squared Error,side=1,line=0.8,cex=1.5)


par(mar=c(2,0,1.8,12))
plot(mse.alpha2$lambda[mse.alpha2$nsample==1000],
 mse.alpha2$mse.naive[mse.alpha2$nsample== 1000],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,.17), cex.lab=1.5
 #,main=yaxs default
)
lines(mse.alpha2$lambda[mse.alpha2$nsample== 
1000],mse.alpha2$mse.RegCal[mse.alpha2$nsample==250],col=2,lty=2)
lines(mse.alpha2$lambda[mse.alpha2$nsample== 
1000],mse.alpha2$mse.PL[mse.alpha2$nsample== 1000],col=3,lty=3)
box()
tab.title(alpha 2 N sample=1000,tab.col=#ff33cc,cex=1)

legend(115,1.8,
   c(alpha 1 N sample=50,alpha 1 N sample=250,alpha 1 N sample=1000,
 alpha 2 N sample=50,alpha 2 N sample=250,alpha 2 N sample=1000),
   fill=c(#88dd88,#dd8800,#dd,#aabbcc,#ddbc44,#ff33cc),
   xpd=NA)


legend(115,1.8,
   c(Naive, Regression Calibration, Pseudo Likelihood), 
   bty = n,col=c(4,2,3),lty=c(4,2,3),
   xpd=NA)



and I got:








Thanks again for your help ;)

Atenciosamente,
Rosa Oliveira

-- 



Rosa Celeste dos Santos Oliveira, 

E-mail: rosit...@gmail.com
Tlm: +351 939355143 
Linkedin: https://pt.linkedin.com/in/rosacsoliveira

Many admire, few know
Hippocrates

 On 08 Jul 2015, at 11:35, Dennis Murphy djmu...@gmail.com wrote:
 
 Hi:
 
 The general process for doing this kind of thing in either ggplot2 or
 lattice 

Re: [R] multiple graphs with a single legend and trellis graph

2015-07-08 Thread Rosa Oliveira
Dear Jim,

first of all, thank you very much :) 
when I run the code:

myDF - rbind(mse.alpha1, mse.alpha2)  # assumes both data frames have the same 
variables in the same order


myDF$ID - factor(rep(c(alpha1, alpha2), times =
c(nrow(mse.alpha1), nrow(mse.alpha2))) )   


library(reshape2)
myDF.melt - melt(myDF, id = c(ID, nsample, lambda), measure =
c(mse.naive, mse.RegCal, mse.PL))  #Melt the three columns to be plotted, 
something like

library(ggplot2)
ggplot(myDF.melt, aes(x = lambda, y = value, color = variable)) +
   geom_point() + geom_line() +
   facet_grid(ID ~ nsample) +
   labs(x = expression(paste(lambda)), y = MSE, color = Type”)



 I get the attached graph. I also attach my data, so you can see :)

I’m I able to resize the graphs differently? I.e. for alpha1: ylim=ylim=c(0,.6) 
and for alpha2: ylim=c(0,.17)? 
I reshaped, a new variable in sample was created, NA, Was it me that made 
something wrong?

I’m very naive and new in R :(

Thanks again ;)







Atenciosamente,
Rosa Oliveira

-- 



Rosa Celeste dos Santos Oliveira, 

E-mail: rosit...@gmail.com
Tlm: +351 939355143 
Linkedin: https://pt.linkedin.com/in/rosacsoliveira

Many admire, few know
Hippocrates

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Re: [R] multiple graphs with a single legend and trellis graph

2015-07-08 Thread John Kane
Hi Rosa,
Neither the graph nor the data arrived.  R-help can be very fussy about what 
attached files it will accept. Usually pdf, txt and png, I think, will come 
through.

In any case it is much better to supply data using the dput() function See 
?dput or have a look at 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
 and http://adv-r.had.co.nz/Reproducibility.html for how to do this.

It is best to use dput() rather than supplying a data file because dput() 
ensures that we get an exact copy of the data as it exists on your computer.  
There is no real guarantee that I will read in a data file the same way as you 
have.



John Kane
Kingston ON Canada


 -Original Message-
 From: rosit...@gmail.com
 Sent: Wed, 8 Jul 2015 13:11:34 +0100
 To: djmu...@gmail.com, drjimle...@gmail.com, r-help@r-project.org
 Subject: Re: [R] multiple graphs with a single legend and trellis graph
 
 Dear Jim,
 
 first of all, thank you very much :)
 when I run the code:
 
 myDF - rbind(mse.alpha1, mse.alpha2)  # assumes both data frames have
 the same variables in the same order
 
 
 myDF$ID - factor(rep(c(alpha1, alpha2), times =
 c(nrow(mse.alpha1), nrow(mse.alpha2))) )
 
 
 library(reshape2)
 myDF.melt - melt(myDF, id = c(ID, nsample, lambda), measure =
 c(mse.naive, mse.RegCal, mse.PL))  #Melt the three columns to be
 plotted, something like
 
 library(ggplot2)
 ggplot(myDF.melt, aes(x = lambda, y = value, color = variable)) +
geom_point() + geom_line() +
facet_grid(ID ~ nsample) +
labs(x = expression(paste(lambda)), y = MSE, color = Type”)
 
 
 
  I get the attached graph. I also attach my data, so you can see :)
 
 I’m I able to resize the graphs differently? I.e. for alpha1:
 ylim=ylim=c(0,.6) and for alpha2: ylim=c(0,.17)?
 I reshaped, a new variable in sample was created, NA, Was it me that made
 something wrong?
 
 I’m very naive and new in R :(
 
 Thanks again ;)
 
 
 
 
 
 
 
 Atenciosamente,
 Rosa Oliveira
 
 --
 
 
 
 Rosa Celeste dos Santos Oliveira,
 
 E-mail: rosit...@gmail.com
 Tlm: +351 939355143
 Linkedin: https://pt.linkedin.com/in/rosacsoliveira
 
 Many admire, few know
 Hippocrates
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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.


FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Re: [R] multiple graphs with a single legend and trellis graph

2015-07-07 Thread David Winsemius

On Jul 7, 2015, at 2:45 PM, Rosa Oliveira wrote:

 Iam trying to plot 6 graphs in one single plot and I was able to, nonetheless 
 I wanted that all graphs had just 1 common legend, as the legend is the same 
 for all the 6 graphs and there is no sense in repeating it 6 times and even 
 more, the legends in each graph sometimes don’t fit the graph.
 
 Is there a way to put just one legend for all the 6 graphs ate the same time?
 
 I was told to use a trellis graph, but after days of trying to do that I 
 wasn’t able to.
 
 Can anyone help me? 
 
 
 library(ggplot2)
 library(reshape)


 library(lattice)

Why did you load those packages above? As far as I can see you did not use any 
lattice or ggplot2 functions. (Also see no reshape or reshape2 functions in 
use.)

 par(mfrow=c(2,3))
 mse.alpha1 -read.csv(file=graphs_mse_alpha1.csv,head=TRUE,sep=,)

And there you lose us. We are unable to see your data. The `legend` function 
can put the legend anywhere. You may need to set par(xpd=TRUE) if the location 
is outside the current plot area. If you wnated just one legend then you mus 
ask yourself why you are issuing multiple legend calls. I see the 
token-`legend` a total of 12 times in the code below.


 attach(mse.alpha1)
 names(mse1000.alpha1)
 mse.alpha2 -read.csv(file=graphs_mse_alpha2.csv,head=TRUE,sep=,)
 attach(mse.alpha2)
 names(mse.alpha2)
 nsample==50
 
 plot(mse.alpha1$lambda[mse.alpha1$nsample==50],
 mse.alpha1$mse.naive[mse.alpha1$nsample==50],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,1), cex.lab=1.5
 )
 lines(mse.alpha1$lambda[mse.alpha1$nsample==50],mse.alpha1$mse.RegCal[mse.alpha1$nsample==50],col=2,lty=2)
 lines(mse.alpha1$lambda[mse.alpha1$nsample==50],mse.alpha1$mse.PL[mse.alpha1$nsample==50],col=3,lty=3)
 title ( expression (paste (Mean squared error for , alpha[1])), 
 cex.main=1.5)
 title(\n\n sample size=50)
 legend(.7,1, legend= c(Naive, Regression Calibration, Pseudo 
 Likelihood), bty = n,col=c(4,2,3),lty=c(4,2,3))
 
 plot(mse.alpha1$lambda[mse.alpha1$nsample==250],
 mse.alpha1$mse.naive[mse.alpha1$nsample==250],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,1), cex.lab=1.5
 )
 lines(mse.alpha1$lambda[mse.alpha1$nsample==250],mse.alpha1$mse.RegCal[mse.alpha1$nsample==250],col=2,lty=2)
 lines(mse.alpha1$lambda[mse.alpha1$nsample==250],mse.alpha1$mse.PL[mse.alpha1$nsample==250],col=3,lty=3)
 title ( expression (paste (Mean squared error for , alpha[1])), 
 cex.main=1.5)
 title(\n\n sample size=250)
 legend(.7,1, legend= c(Naive, Regression Calibration, Pseudo 
 Likelihood), bty = n,col=c(4,2,3),lty=c(4,2,3))
 
 
 plot(mse.alpha1$lambda[mse.alpha1$nsample==1000],
 mse.alpha1$mse.naive[mse.alpha1$nsample== 1000],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,1), cex.lab=1.5
 )
 lines(mse.alpha1$lambda[mse.alpha1$nsample== 
 1000],mse.alpha1$mse.RegCal[mse.alpha1$nsample== 1000],col=2,lty=2)
 lines(mse.alpha1$lambda[mse.alpha1$nsample== 
 1000],mse.alpha1$mse.PL[mse.alpha1$nsample== 1000],col=3,lty=3)
 title ( expression (paste (Mean squared error for , alpha[1])), 
 cex.main=1.5)
 title(\n\n sample size=1000)
 legend(.7,1, legend= c(Naive, Regression Calibration, Pseudo 
 Likelihood), bty = n,col=c(4,2,3),lty=c(4,2,3))
 
 plot(mse.alpha2$lambda[mse.alpha2$nsample==50],
 mse.alpha2$mse.naive[mse.alpha2$nsample==50],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,.17), cex.lab=1.5
 )
 lines(mse.alpha2$lambda[mse.alpha2$nsample==50],mse.alpha2$mse.RegCal[mse.alpha2$nsample==50],col=2,lty=2)
 lines(mse.alpha2$lambda[mse.alpha2$nsample==50],mse.alpha2$mse.PL[mse.alpha2$nsample==50],col=3,lty=3)
 title ( expression (paste (Mean squared error for , alpha[2])), 
 cex.main=1.5)
 title(\n\n sample size=50)
 legend(.7,.17, legend= c(Naive, Regression Calibration, Pseudo 
 Likelihood), bty = n,col=c(4,2,3),lty=c(4,2,3))
 
 
 plot(mse.alpha2$lambda[mse.alpha2$nsample==250],
 mse.alpha2$mse.naive[mse.alpha2$nsample==250],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,.17), cex.lab=1.5
 )
 lines(mse.alpha2$lambda[mse.alpha2$nsample==250],mse.alpha2$mse.RegCal[mse.alpha2$nsample==250],col=2,lty=2)
 lines(mse.alpha2$lambda[mse.alpha2$nsample==250],mse.alpha2$mse.PL[mse.alpha2$nsample==250],col=3,lty=3)
 title ( expression (paste (Mean squared error for , alpha[2])), 
 cex.main=1.5)
 title(\n\n sample size=250)
 legend(.7,.17, legend= c(Naive, Regression Calibration, Pseudo 
 Likelihood), bty = n,col=c(4,2,3),lty=c(4,2,3))
 
 plot(mse.alpha2$lambda[mse.alpha2$nsample==1000],
 mse.alpha2$mse.naive[mse.alpha2$nsample== 1000],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,.17), cex.lab=1.5
 )
 lines(mse.alpha2$lambda[mse.alpha2$nsample== 
 1000],mse.alpha2$mse.RegCal[mse.alpha2$nsample==250],col=2,lty=2)
 lines(mse.alpha2$lambda[mse.alpha2$nsample== 
 

Re: [R] multiple graphs, lapply and different titles

2012-10-19 Thread David Winsemius

On Oct 19, 2012, at 12:30 PM, Flavio Barros wrote:

 I have a list of data.frames, and i want to iterate over this list and
 generate graphs with the same title of the data.frame.
 
 I did the graphs with:
 
 lapply(anual, function(x) plot(x[,'chuva'], type='l', xlab= 'anos', ylab =
 'Precicipatação(mm)', col='red'))
 
 where anual is list of data.frames. I am plotting just the column chuva
 at each data.frame.
 
 How can i do that?

Easiest way would be to iterate over the names of the list 'anual' and then use 
nam as your formal argument,  pull each data.frame in from 'anual' with 
anual[nam] and use main=nam in the plot command.

 and provide commented, minimal, self-contained, reproducible code.

Had you provided a self-contained example I would have offered tested code in 
return.

-- 

David Winsemius, MD
Alameda, CA, USA

__
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.


Re: [R] Multiple graphs boxplot

2012-10-06 Thread John Kane
Does something like this make any sense?

library(reshape2)
library(ggplot2)
yy  -  structure(list(A = c(23, 21, 21, 20, 19, 19), B = c(20, 18, 20, 
19, 20, 18), C = c(15, 15, 15, 12, 13, 13)), .Names = c(A, 
B, C), class = data.frame, row.names = c(NA, -6L))

y1  -  melt(yy)  # using reshape2 

ggplot(y1, aes(variable, value))+ geom_boxplot() 

# or

ggplot(y1, aes(variable, value))+ geom_boxplot()  + facet_grid(variable ~ .)




John Kane
Kingston ON Canada


 -Original Message-
 From: dagr...@hotmail.com
 Sent: Fri, 5 Oct 2012 18:01:39 +0200
 To: r-help@r-project.org
 Subject: [R] Multiple graphs  boxplot
 
 
 
 Dear all
 
 I am trying to represent a dependent variable (treatment) against
 different independent variables (v1, v2, v3v20). I am using the
 following command:
 
 boxplot(v1~treatment,data=y, main=xx,xlab=xx, ylab=xx)
 
 However, it provides me only one graph for v1~treatment. For the other
 comparisons, I have to repeat the same command but changing the
 parameters. My intentions is to get different plots in just one sheet
 using only one command. Is it possible to join the same order for all the
 comparisons in only one command?
 
 Thanks
 David
 
   [[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.


FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
family!
Visit http://www.inbox.com/photosharing to find out more!

__
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.


Re: [R] Multiple graphs boxplot

2012-10-05 Thread Rui Barradas

Hello,

I've once written a function that does more or less what you want, but 
it has no formula interface.


# Input:
#x - matrix or data.frame of numeric vectors to graph
#by - a factor or coercible to factor
multi.boxplot - function(x, by, col=0, ...){
x - as.data.frame(x)
uniq.by - unique(by)
by - factor(by)
len - length(uniq.by) - 1
n - ncol(x)
n1 - n + 1
col - rep(col, n)[seq_len(n)]
boxplot(x[[ 1 ]] ~ by, at = 0:len*n1 + 1,
xlim = c(0, (len + 1)*n1), ylim = range(unlist(x)), xaxt = n, 
col=col[1], ...)

for(i in seq_len(n)[-1])
boxplot(x[[i]] ~ by, at = 0:len*n1 + i, xaxt = n, add = TRUE, 
col=col[i], ...)

axis(1, at = 0:len*n1 + n1/2, labels = uniq.by, tick = TRUE)
}


a - matrix(data=runif(300,max=2), nrow=100, ncol=3)
fac - sample(letters[1:4], 100, TRUE)

multi.boxplot(a, fac)


Hope this helps,

Rui Barradas
Em 05-10-2012 17:01, David Gramaje escreveu:


Dear all

I am trying to represent a dependent variable (treatment) against different 
independent variables (v1, v2, v3v20). I am using the following command:

boxplot(v1~treatment,data=y, main=xx,xlab=xx, ylab=xx)

However, it provides me only one graph for v1~treatment. For the other 
comparisons, I have to repeat the same command but changing the parameters. My 
intentions is to get different plots in just one sheet using only one command. 
Is it possible to join the same order for all the comparisons in only one 
command?

Thanks
David

[[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.


__
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.


Re: [R] Multiple graphs

2011-03-14 Thread Jim Lemon

On 03/14/2011 06:22 PM, Akshata Rao wrote:

...
However, there is only one small problem with the graphs. The graph doesn't
give me the asset names. I.e. in the graph which is meant for bank doesn't
show me the name bank. Under the X - label i.e. Rating, it gives me number
1, Similarly for corporate and sovereign it gives the numbers 2 and 3
respectively.


Hi Akshata,
Try this:

DP_graphs - function(Data = output, class.var=basel_asset_class_id,
 class.labels=NULL,ratings=internal_scale_id,
 IPD=default_probability) {
   class - unique(as.character(Data[[class.var]]))[1]
   png(filename=sprintf(%s%s%s%s%s, Curve ,
( , class, ),.png),width=480,height=480)
   par('bg'= #CC)
   par(xaxt=n)
   # if the labels are not specified, default to the numbers
   if(is.null(class.labels)) class.labels-unique(class)
   # stick your labels together here
   class.labels-paste((,class.labels,),sep=)
   plot(as.numeric(factor(Data[[ratings]])), Data[[IPD]],
   b,ylab=PD, xlab=Rating,
fg=#804000, font.main=2,cex.main=1,col=Red,
col.main=black,col.axis=black ,col.lab = black)
   # replace the class numbers with the appropriate labels
   title(Exponential Curve, sub=class.labels[as.numeric(class)],
cex.main=1.2,font.main= 2, col.main= black, cex.sub = 1,
font.sub = 2, col.sub =black)
   par(xaxt=s)
   axis(1,at=1:length(unique(output$internal_scale_id)), labels =
internal_scale)
   box(which=outer,bty = o, col = #804000)
   dev.off()
}

d_ply(output, .(basel_asset_class_id), DP_graphs,
 class.labels=c(bank,corporate,sovreign))

Jim

__
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.


Re: [R] multiple graphs

2010-09-08 Thread moleps
Problem solved..

My bad. No prb with cdplot or graphics-part. The problem was the a-list.. 
command which resulted in all three levels of bar$h.r in a[[1]]. Skipping the 
list function sorted it out.


par(mfrow=c(2,2))
a-levels(bar$h.r)[c(1,3,6)]
print(a)
lapply(a,function(x){
a-subset(bar,h.r==x)
with(a, cdplot(wh~Age,ylab=x))
#plot.new()
})

Regards,

//M



On 8. sep. 2010, at 03.37, David Winsemius wrote:

 
 On Sep 7, 2010, at 8:02 PM, moleps wrote:
 
 Dear all,
 
 I´m trying to create multiple graphs on the same page, but they are all 
 stacked on top of each other.
 
 My code:
 
 
 par(mfrow=c(2,2))
 a-list(levels(bar$h.r)[c(1,3,6)])
 print(a)
 
 lapply(a,function(x){
  a-subset(bar,h.r==x)
  with(a, cdplot(wh~Age,ylab=x))
  #plot.new()
  })
 
 The plot.new command doesnt help...
 
 Any ideas??
 
 ?layout  # assuming that the undescribed plotting function is base graphics. 
 Some plotting functions are hard coded and are able to defeat the usual 
 formatting options.
 
 -- 
 David Winsemius, MD
 West Hartford, CT
 

__
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.


Re: [R] multiple graphs

2010-09-07 Thread David Winsemius


On Sep 7, 2010, at 8:02 PM, moleps wrote:


Dear all,

I´m trying to create multiple graphs on the same page, but they are  
all stacked on top of each other.


My code:


par(mfrow=c(2,2))
a-list(levels(bar$h.r)[c(1,3,6)])
print(a)

lapply(a,function(x){
a-subset(bar,h.r==x)
with(a, cdplot(wh~Age,ylab=x))
#plot.new()
})

The plot.new command doesnt help...

Any ideas??


?layout  # assuming that the undescribed plotting function is base  
graphics. Some plotting functions are hard coded and are able to  
defeat the usual formatting options.


--
David Winsemius, MD
West Hartford, CT

__
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.


Re: [R] Multiple graphs

2009-07-28 Thread Alain Zuur



Data Analytics Corp. wrote:
 
 Hi,
 
 I wrote a simple master function, run(), that has inside six qplot 
 functions.  The goal is to type run() and have all six graphs appear as 
 separate windows so that I can copy them into PowerPoint for a client. 
 When I type run(), only the last graph appears, the first five 
 apparently being overwritten.  How do I get all six in separate windows, 
 ready for copying?
 
 By the way, is the a way to create a PowerPoint deck directly in R the 
 way you can in S-Plus?
 
 Thanks,
 
 Walt
 
 
 
 -- 
 
 
 Walter R. Paczkowski, Ph.D.
 Data Analytics Corp.
 44 Hamilton Lane
 Plainsboro, NJ 08536
 
 (V) 609-936-8999
 (F) 609-936-3733
 dataanalyt...@earthlink.net
 www.dataanalyticscorp.com
 
 __
 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.
 
 


There is an example in our A Beginner's Guide to R that exports the graphs
automatically to jpg files (from a  loop inside a function)...which you
could then import into powerpoint. But as you can see from the other post,
it can even be done automatically. 


Alain 

-

Dr. Alain F. Zuur
First author of:

1. Analysing Ecological Data (2007).
Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p.

2. Mixed effects models and extensions in ecology with R. (2009).
Zuur, AF, Ieno, EN, Walker, N, Saveliev, AA, and Smith, GM. Springer.

3. A Beginner's Guide to R (2009).
Zuur, AF, Ieno, EN, Meesters, EHWG. Springer


Statistical consultancy, courses, data analysis and software
Highland Statistics Ltd.
6 Laverock road
UK - AB41 6FN Newburgh
Email: highs...@highstat.com
URL: www.highstat.com



-- 
View this message in context: 
http://www.nabble.com/Multiple-graphs-tp24690227p24697026.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] Multiple graphs

2009-07-27 Thread Cedrick Johnson

Try dev.new() after each graph is generated.

Example code from my setup (adapted a bit to fit your situation):

Alternate Method 1: Generate images and insert into PPT

png(file = chart1.png, width=800, height=800)
#do something pretty
dev.off()


Alternate Method 2: Generate images with new windows
dev.new()
#do something pretty


Check out the library R2PPT to answer your question about interaction 
with PPT.


Also, don't know if you're using the new Offce 2007, the default fonts 
with Calibri, etc. will be different (R generates them in the default 
font Arial). You can set it so that you match Office2K7 (or any other 
font of your choice) for consistency with the graphs generated in R and 
the rest of your presentation by doing the following:


windowsFonts(calibri = windowsFont(Calibri))
windowsFonts(consolas = windowsFont(Consolas))
dev.new()
par(family=calibri)  #Office 2K7 default font
#do something pretty

HTH,
Cedrick


Data Analytics Corp. wrote:

Hi,

I wrote a simple master function, run(), that has inside six qplot 
functions.  The goal is to type run() and have all six graphs appear 
as separate windows so that I can copy them into PowerPoint for a 
client. When I type run(), only the last graph appears, the first five 
apparently being overwritten.  How do I get all six in separate 
windows, ready for copying?


By the way, is the a way to create a PowerPoint deck directly in R the 
way you can in S-Plus?


Thanks,

Walt





__
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.