side by side plots

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

side by side plots

H. Paul Benton
Hello everyone,

I have an overlay plot it's nice but you can't see all the data. I would
like to know if there is a way to get a plot that gives a side by side
plot so that  each plot would be next to each other. The two plots have
the same data are of different species. At the moment this is the code I'm
using:

exp<-cbind(abs(round(rnorm(10),2)*10), seq(100, 200, by=10))
ref<-cbind(abs(round(rnorm(10),2)*10), seq(100, 200, by=10))

plot(ref, ylab="Intensity", xlab="wavelength", type="h")
points(exp, type="h", col="red")

This is working in a script and I would like to have a single pdf/png file
for the user with this plot, rather than asking the user to manually
compare them.

Any ideas on how I would do this?

Thanks

Paul

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: side by side plots

Sundar Dorai-Raj


[hidden email] said the following on 1/7/2008 2:59 PM:

> Hello everyone,
>
> I have an overlay plot it's nice but you can't see all the data. I would
> like to know if there is a way to get a plot that gives a side by side
> plot so that  each plot would be next to each other. The two plots have
> the same data are of different species. At the moment this is the code I'm
> using:
>
> exp<-cbind(abs(round(rnorm(10),2)*10), seq(100, 200, by=10))
> ref<-cbind(abs(round(rnorm(10),2)*10), seq(100, 200, by=10))
>
> plot(ref, ylab="Intensity", xlab="wavelength", type="h")
> points(exp, type="h", col="red")
>
> This is working in a script and I would like to have a single pdf/png file
> for the user with this plot, rather than asking the user to manually
> compare them.
>
> Any ideas on how I would do this?
>
> Thanks
>
> Paul
>
> ______________________________________________
> [hidden email] 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.

Hi, Paul,

Simple enough in lattice:

library(lattice)
z <- rbind(cbind(as.data.frame(exp), type = "exp"),
            cbind(as.data.frame(ref), type = "ref"))
z$type <- factor(z$type, levels = c("ref", "exp"))
xyplot(V2 ~ V1 | type, data = z, type = "h")

HTH,

--sundar

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: side by side plots

Domenico Vistocco
In reply to this post by H. Paul Benton
[hidden email] wrote:

> Hello everyone,
>
> I have an overlay plot it's nice but you can't see all the data. I would
> like to know if there is a way to get a plot that gives a side by side
> plot so that  each plot would be next to each other. The two plots have
> the same data are of different species. At the moment this is the code I'm
> using:
>
> exp<-cbind(abs(round(rnorm(10),2)*10), seq(100, 200, by=10))
> ref<-cbind(abs(round(rnorm(10),2)*10), seq(100, 200, by=10))
>
> plot(ref, ylab="Intensity", xlab="wavelength", type="h")
> points(exp, type="h", col="red")
>
> This is working in a script and I would like to have a single pdf/png file
> for the user with this plot, rather than asking the user to manually
> compare them.
>  
For the pdf/png see:
?png
?pdf

domenico

> Any ideas on how I would do this?
>
> Thanks
>
> Paul
>
> ______________________________________________
> [hidden email] 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.
>
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: side by side plots

Dylan Beaudette-2
In reply to this post by H. Paul Benton
On Monday 07 January 2008, [hidden email] wrote:

> Hello everyone,
>
> I have an overlay plot it's nice but you can't see all the data. I would
> like to know if there is a way to get a plot that gives a side by side
> plot so that  each plot would be next to each other. The two plots have
> the same data are of different species. At the moment this is the code I'm
> using:
>
> exp<-cbind(abs(round(rnorm(10),2)*10), seq(100, 200, by=10))
> ref<-cbind(abs(round(rnorm(10),2)*10), seq(100, 200, by=10))
>
> plot(ref, ylab="Intensity", xlab="wavelength", type="h")
> points(exp, type="h", col="red")
>
> This is working in a script and I would like to have a single pdf/png file
> for the user with this plot, rather than asking the user to manually
> compare them.
>
> Any ideas on how I would do this?
>
> Thanks
>
> Paul

have a look at ?par , specifically par(mfcol=c(...))

cheers,
Dylan



--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: side by side plots

John Kane-2
In reply to this post by H. Paul Benton
?par  and have a look at mfcol or mfrow.

Example
exp<-cbind(abs(round(rnorm(10),2)*10), seq(100, 200,
by=10))
ref<-cbind(abs(round(rnorm(10),2)*10), seq(100, 200,
by=10))
op <- par(mfrow=c(1,2))
plot(ref, col="red")
plot(exp, col="blue")
par(op)
--- [hidden email] wrote:

> Hello everyone,
>
> I have an overlay plot it's nice but you can't see
> all the data. I would
> like to know if there is a way to get a plot that
> gives a side by side
> plot so that  each plot would be next to each other.
> The two plots have
> the same data are of different species. At the
> moment this is the code I'm
> using:
>
> exp<-cbind(abs(round(rnorm(10),2)*10), seq(100, 200,
> by=10))
> ref<-cbind(abs(round(rnorm(10),2)*10), seq(100, 200,
> by=10))
>
> plot(ref, ylab="Intensity", xlab="wavelength",
> type="h")
> points(exp, type="h", col="red")
>
> This is working in a script and I would like to have
> a single pdf/png file
> for the user with this plot, rather than asking the
> user to manually
> compare them.
>
> Any ideas on how I would do this?
>
> Thanks
>
> Paul
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.