[R] Scatter Plot in R - Help

2007-04-27 Thread A Ezhil
Dear All,

I am using the following commands to do the scatter
plot of two vectors, say X and Y.

plot(X,Y, col=blue)
abline(a=1,b=1, col=red)
abline(a=-1,b=1, col=green)

I would like to split the scatter plot into 3 part
with 3 different colors: (i) points lies between 2
lines, (ii) points above line 1, and (iii) points
below line 2. I am struggling to do this. I would
greatly appreciate any help in doing this.

Thanks in advance.

Kind regards,
Ezhil

__
R-help@stat.math.ethz.ch 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] Scatter Plot in R - Help

2007-04-27 Thread J . delasHeras
Quoting A Ezhil [EMAIL PROTECTED]:

 Dear All,

 I am using the following commands to do the scatter
 plot of two vectors, say X and Y.

 plot(X,Y, col=blue)
 abline(a=1,b=1, col=red)
 abline(a=-1,b=1, col=green)

 I would like to split the scatter plot into 3 part
 with 3 different colors: (i) points lies between 2
 lines, (ii) points above line 1, and (iii) points
 below line 2. I am struggling to do this. I would
 greatly appreciate any help in doing this.

 Thanks in advance.

 Kind regards,
 Ezhil

check ?points

'points' allows you to plot points using different plotting parameters  
(type, size, colours...).
You can subset the points in your scatter plot into three groups, and  
use 'points' on each group separately.

For instance:

x-sample(c(-10:10),size=21)
y-sample(c(-10:10),size=21)
plot(x,y, col=blue,pch=16)
abline(a=1,b=1, col=red)
abline(a=-1,b=1, col=green)
# then find the red and green groups:
reds-which(yx+1)
greens-which(xy+1)
points(x[reds],y[reds], col=red,pch=16)
points(x[greens],y[greens], col=green,pch=16)

you could also choose to not plot anything at first (use parameter  
type=n), and define not just the red and green groups, but also teh  
blue ones too. You may need to do this if you want to use different  
plotting characters or sizes and overplotting doesn't look good.

Jose


-- 
Dr. Jose I. de las Heras  Email: [EMAIL PROTECTED]
The Wellcome Trust Centre for Cell BiologyPhone: +44 (0)131 6513374
Institute for Cell  Molecular BiologyFax:   +44 (0)131 6507360
Swann Building, Mayfield Road
University of Edinburgh
Edinburgh EH9 3JR
UK

__
R-help@stat.math.ethz.ch 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] Scatter Plot in R - Help

2007-04-27 Thread John Kane
Here is a recent posting by Petr Klasterecky  that
does not seem to be on the archive yet that may help.
--

What do you mean by background? Maybe this is enough:

plot(seq(-3,3,.01), dnorm(seq(-3,3,.01)), type=n,
xlab=x, 
ylab=f(x), main=Normal density)
polygon(x=c(-4,0,0,-4), y=c(-1,-1,.5,.5), col=red)
polygon(x=c(4,0,0,4), y=c(-1,-1,.5,.5), col=blue)
lines(seq(-3,3,.01), dnorm(seq(-3,3,.01)), type=l,
lwd=2)

Play a little bit with the polygon margins to get what
you need. You 
can 
even generate them automatically based on your data.

Petr
---
--- A Ezhil [EMAIL PROTECTED] wrote:

 Dear All,
 
 I am using the following commands to do the scatter
 plot of two vectors, say X and Y.
 
 plot(X,Y, col=blue)
 abline(a=1,b=1, col=red)
 abline(a=-1,b=1, col=green)
 
 I would like to split the scatter plot into 3 part
 with 3 different colors: (i) points lies between 2
 lines, (ii) points above line 1, and (iii) points
 below line 2. I am struggling to do this. I would
 greatly appreciate any help in doing this.
 
 Thanks in advance.
 
 Kind regards,
 Ezhil
 
 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] Scatter Plot in R - Help

2007-04-27 Thread Petr Klasterecky
If I understand correctly what A. Ezhil asked for, polygons won't help 
here. For coloring the individual points check ?points and use subsets, e.g.

plot(x,y)
points(x[xy-1],y[xy-1], col=red)

or something similar.
Petr

John Kane napsal(a):
 Here is a recent posting by Petr Klasterecky  that
 does not seem to be on the archive yet that may help.
 --
 
 What do you mean by background? Maybe this is enough:
 
 plot(seq(-3,3,.01), dnorm(seq(-3,3,.01)), type=n,
 xlab=x, 
 ylab=f(x), main=Normal density)
 polygon(x=c(-4,0,0,-4), y=c(-1,-1,.5,.5), col=red)
 polygon(x=c(4,0,0,4), y=c(-1,-1,.5,.5), col=blue)
 lines(seq(-3,3,.01), dnorm(seq(-3,3,.01)), type=l,
 lwd=2)
 
 Play a little bit with the polygon margins to get what
 you need. You 
 can 
 even generate them automatically based on your data.
 
 Petr
 ---
 --- A Ezhil [EMAIL PROTECTED] wrote:
 
 Dear All,

 I am using the following commands to do the scatter
 plot of two vectors, say X and Y.

 plot(X,Y, col=blue)
 abline(a=1,b=1, col=red)
 abline(a=-1,b=1, col=green)

 I would like to split the scatter plot into 3 part
 with 3 different colors: (i) points lies between 2
 lines, (ii) points above line 1, and (iii) points
 below line 2. I am struggling to do this. I would
 greatly appreciate any help in doing this.

 Thanks in advance.

 Kind regards,
 Ezhil

 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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.
 

-- 
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic

__
R-help@stat.math.ethz.ch 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] Scatter Plot in R - Help

2007-04-27 Thread John Kane
When I reread it, I think you are right. I read split
the data plot and assumed a backround rather than just
the points .  
--- Petr Klasterecky [EMAIL PROTECTED]
wrote:

 If I understand correctly what A. Ezhil asked for,
 polygons won't help 
 here. For coloring the individual points check
 ?points and use subsets, e.g.
 
 plot(x,y)
 points(x[xy-1],y[xy-1], col=red)
 
 or something similar.
 Petr
 
 John Kane napsal(a):
  Here is a recent posting by Petr Klasterecky  that
  does not seem to be on the archive yet that may
 help.
  --
  
  What do you mean by background? Maybe this is
 enough:
  
  plot(seq(-3,3,.01), dnorm(seq(-3,3,.01)),
 type=n,
  xlab=x, 
  ylab=f(x), main=Normal density)
  polygon(x=c(-4,0,0,-4), y=c(-1,-1,.5,.5),
 col=red)
  polygon(x=c(4,0,0,4), y=c(-1,-1,.5,.5),
 col=blue)
  lines(seq(-3,3,.01), dnorm(seq(-3,3,.01)),
 type=l,
  lwd=2)
  
  Play a little bit with the polygon margins to get
 what
  you need. You 
  can 
  even generate them automatically based on your
 data.
  
  Petr
  ---
  --- A Ezhil [EMAIL PROTECTED] wrote:
  
  Dear All,
 
  I am using the following commands to do the
 scatter
  plot of two vectors, say X and Y.
 
  plot(X,Y, col=blue)
  abline(a=1,b=1, col=red)
  abline(a=-1,b=1, col=green)
 
  I would like to split the scatter plot into 3
 part
  with 3 different colors: (i) points lies between
 2
  lines, (ii) points above line 1, and (iii) points
  below line 2. I am struggling to do this. I would
  greatly appreciate any help in doing this.
 
  Thanks in advance.
 
  Kind regards,
  Ezhil
 
  __
  R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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.
  
 
 -- 
 Petr Klasterecky
 Dept. of Probability and Statistics
 Charles University in Prague
 Czech Republic


__
R-help@stat.math.ethz.ch 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] scatter plot with axes drawn on the same scale

2006-07-28 Thread bogdan romocea
Dear useRs,

I'd like to produce some scatter plots where N units on the X axis are
equal to N units on the Y axis (as measured with a ruler, on screen or
paper). This approach
  x - sample(10:200,40) ; y - sample(20:100,40)
  windows(width=max(x),height=max(y))
  plot(x,y)
is better than plot(x,y) but doesn't solve the problem because of the
other parameters (margins etc). Is there an easy, official way of
sizing the axes to the same scale, one that would also work with
multiple scatter plots being sent to the same pdf() - plus perhaps
layout() or par(mfrow())?

Thank you,
b.

__
R-help@stat.math.ethz.ch 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] scatter plot with axes drawn on the same scale

2006-07-28 Thread Sundar Dorai-Raj
Try:

plot(x, y, asp = 1)

--sundar

bogdan romocea wrote:
 Dear useRs,
 
 I'd like to produce some scatter plots where N units on the X axis are
 equal to N units on the Y axis (as measured with a ruler, on screen or
 paper). This approach
   x - sample(10:200,40) ; y - sample(20:100,40)
   windows(width=max(x),height=max(y))
   plot(x,y)
 is better than plot(x,y) but doesn't solve the problem because of the
 other parameters (margins etc). Is there an easy, official way of
 sizing the axes to the same scale, one that would also work with
 multiple scatter plots being sent to the same pdf() - plus perhaps
 layout() or par(mfrow())?
 
 Thank you,
 b.
 
 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] scatter plot with axes drawn on the same scale

2006-07-28 Thread Ben Bolker
Sundar Dorai-Raj sundar.dorai-raj at pdf.com writes:

 
 Try:
 
 plot(x, y, asp = 1)
 
 --sundar
 
 

  or eqscplot from the MASS package.

__
R-help@stat.math.ethz.ch 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] scatter plot with axes drawn on the same scale

2006-07-28 Thread Deepayan Sarkar
On 7/28/06, Ben Bolker [EMAIL PROTECTED] wrote:
 Sundar Dorai-Raj sundar.dorai-raj at pdf.com writes:

 
  Try:
 
  plot(x, y, asp = 1)
 
  --sundar
 
 

   or eqscplot from the MASS package.

or

library(lattice)
xyplot(y ~ x, aspect = iso)

-Deepayan

__
R-help@stat.math.ethz.ch 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] scatter plot

2005-08-11 Thread Dean Sonneborn
I'd like to do a simple scatter plot but instead of using the variable 
values on the X axis I would like to plot the percentiles. I searched in 
the manual for percentiles but did not find what I was looking for. I've 
been using SAS for several years but I new to R.

-- 
Dean Sonneborn
Programmer Analyst
Department of Public Health Sciences
University of California, Davis
(916) 734-6656

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] scatter plot

2005-08-11 Thread Adaikalavan Ramasamy
Here is a hack

 par(mfrow=c(1,2))

 x  - rnorm(1000)
 y  - x + rnorm(1000)
 xp - (rank(x)-1)/(length(x)-1)

 plot( x, y )
 plot( xp, y )

But do notice that by using percentiles, it spreads the 'x' values
evenly. This may be important for points at the extremes.

Regards, Adai



On Thu, 2005-08-11 at 15:40 -0700, Dean Sonneborn wrote:
 I'd like to do a simple scatter plot but instead of using the variable 
 values on the X axis I would like to plot the percentiles. I searched in 
 the manual for percentiles but did not find what I was looking for. I've 
 been using SAS for several years but I new to R.


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] scatter plot

2005-08-11 Thread Dean Sonneborn
I'm doing this scatter plot and it's almost what I want. What I would 
like to change is to have the X axis (the lipid_adj_pcb_cent variable) 
be plotted in percentiles not the variable values. Here's the code I 
currently using:

xyplot(zawgt_sk_cent ~ lipid_adj_pcb_cent, panel=function(x,y){

 panel.xyplot(x,y)

 panel.lmline(x,y)}, auto.key=TRUE, data=centered,  na.strings=, 
fontfamily = HersheySans , scales = list(  tick.number = 10))

 

 


-- 
Dean Sonneborn
Programmer Analyst
Department of Public Health Sciences
University of California, Davis
(916) 734-6656


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] scatter plot and marginal

2004-10-04 Thread Paolo Bulla

Hallo,

I would like to add the marginal distributions along the X and the Y axis to a
scatter plot.
Can anybody help me, please?

Thank you,
 Paolo
-- 
Paolo Bulla

Istituto di Metodi Quantitativi
Università L. Bocconi
viale Isonzo 25
20136 Milano
[EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] scatter plot and marginal

2004-10-04 Thread Liaw, Andy
See example(layout).

Andy

 From: Paolo Bulla
 
 Hallo,
 
 I would like to add the marginal distributions along the X 
 and the Y axis to a
 scatter plot.
 Can anybody help me, please?
 
 Thank you,
  Paolo
 -- 
 Paolo Bulla
 
 Istituto di Metodi Quantitativi
 Università L. Bocconi
 viale Isonzo 25
 20136 Milano
 [EMAIL PROTECTED]
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 


__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] scatter plot and marginal

2004-10-04 Thread Marc Schwartz
On Mon, 2004-10-04 at 08:33, Paolo Bulla wrote:
 Hallo,
 
 I would like to add the marginal distributions along the X and the Y axis to a
 scatter plot.
 Can anybody help me, please?
 
 Thank you,
  Paolo


See the last example in ?layout

HTH,

Marc Schwartz

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] scatter plot and marginal

2004-10-04 Thread Kjetil Brinchmann Halvorsen
Paolo Bulla wrote:
Hallo,
I would like to add the marginal distributions along the X and the Y axis to a
scatter plot.
Can anybody help me, please?
Thank you,
Paolo
 

The simplest thing you can do is like
plot(x, y)
rug(x, side=1, col=red)
rug(y, side=2, col=red)
or if there are many coincident x (y) values
rug(jitter(x), side=1, col=red)
rug(jitter(y), side=2, col=red)
Kjetil
--
Kjetil Halvorsen.
Peace is the most effective weapon of mass construction.
  --  Mahdi Elmandjra
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] scatter plot and marginal

2004-10-04 Thread John Fox
Dear Paolo,

The scatterplot() function in the car package can show marginal
boxplots.

I hope this helps,
 John


On Mon,  4 Oct 2004 15:33:26 +0200
 Paolo Bulla [EMAIL PROTECTED] wrote:
 
 Hallo,
 
 I would like to add the marginal distributions along the X and the Y
 axis to a
 scatter plot.
 Can anybody help me, please?
 
 Thank you,
  Paolo
 -- 
 Paolo Bulla
 
 Istituto di Metodi Quantitativi
 Università L. Bocconi
 viale Isonzo 25
 20136 Milano
 [EMAIL PROTECTED]
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Scatter plot matrix over several pages

2004-07-29 Thread John Field
Hello R-helpers,
I'm plotting a scatter plot matrix, but have more variables to consider 
than will legibly fit on one page.  I'd appreciate some help on how I can 
persuade pairs or splom to plot the full matrix of plots over several pages.

With thanks,
John Field
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Scatter Plot Matrix

2003-12-11 Thread Donna Floyd
I am researching the origin and use of the scatter plot matrix or
scatter matrix.

A common event with the normal scatter diagram is the overlaying of
points, given that one (x,y) pair exists and that each (x,y) point
plotted exists at the same point.  What I am wondering is if it is
possible to expand the (x,y) area to form a larger cell, such that
each point plotted would exist distinctly within the larger area.
In the example, each dot represents an (x,y) point that exists
within the bounded area of the (x,y) pair


This possibility allows each point plotted to be distinctly
recognized.

Your thoughts on this would be greatly appreciated.

Donna D. Floyd
USA

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Scatter Plot Matrix

2003-12-11 Thread Prof Brian Ripley
?jitter may help you.

On Thu, 11 Dec 2003, Donna Floyd wrote:

 I am researching the origin and use of the scatter plot matrix or
 scatter matrix.
 
 A common event with the normal scatter diagram is the overlaying of
 points, given that one (x,y) pair exists and that each (x,y) point
 plotted exists at the same point.  What I am wondering is if it is
 possible to expand the (x,y) area to form a larger cell, such that
 each point plotted would exist distinctly within the larger area.
 In the example, each dot represents an (x,y) point that exists
 within the bounded area of the (x,y) pair
 
 
 This possibility allows each point plotted to be distinctly
 recognized.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help