Re: [R] Problem in graph plotting

2009-09-23 Thread Henrique Dallazuanna
Try this:

plot(tp, dp, type =  'l', ylim = rev(range(dp, na.rm = TRUE)))

On Wed, Sep 23, 2009 at 1:44 PM, FMH  wrote:
> Thank you for the code. I found that the coding does not work if there is an 
> NA in dp variable. For instance;
>
> #
> dp <- c(1,4,NA,2,5,7,9,8,9,2)
> tp <- 1:10
> plot(tp,dp, type= 'l',ylim=rev(range(dp)))
>  #
>
> If this is the case, how could we rewrite the coding?
>
> Thank you
> Fir
>
>
>
>
> - Original Message 
> From: jim holtman 
> To: FMH 
> Cc: r-help@r-project.org
> Sent: Wednesday, September 23, 2009 1:04:21 PM
> Subject: Re: [R] Problem in graph plotting
>
> try this:
>
> plot(tp,dp, type= 'l',ylim=rev(range(dp)))
>
>
> On Wed, Sep 23, 2009 at 7:58 AM, FMH  wrote:
>> Dear All,
>>
>> Let:
>> dp: depth of the river
>> tp: temperature with respect to depth
>>
>> We can have a simple scatter plot, between depth as y-axis and temperature 
>> as x-axis, by using a plot function as shown below.
>>
>> #
>> dp <- c(1,4,3,2,5,7,9,8,9,2)
>> tp <- 1:10
>> plot(tp,dp, type= 'l')
>> #
>>
>> Could someone advice me on the way to plot the same pair of observations, 
>> but with depth in descending order from the origin. Instead of depth, I 
>> tried to simply use rev(depth), but the result was bizarre.
>>
>> Thank you
>> Fir
>>
>>
>>
>>
>> __
>> 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.
>>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>
>
>
>
> __
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

__
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] Problem in graph plotting

2009-09-23 Thread baptiste auguie
Try this,

d <- na.omit(data.frame(tp,dp))
plot(d, t="l", ylim=rev(range(d$dp)))

?na.omit

HTH,

baptiste

2009/9/23 FMH :
> Thank you for the code. I found that the coding does not work if there is an 
> NA in dp variable. For instance;
>
> #
> dp <- c(1,4,NA,2,5,7,9,8,9,2)
> tp <- 1:10
> plot(tp,dp, type= 'l',ylim=rev(range(dp)))
>  #
>
> If this is the case, how could we rewrite the coding?
>
> Thank you
> Fir
>
>
>
>
> - Original Message 
> From: jim holtman 
> To: FMH 
> Cc: r-help@r-project.org
> Sent: Wednesday, September 23, 2009 1:04:21 PM
> Subject: Re: [R] Problem in graph plotting
>
> try this:
>
> plot(tp,dp, type= 'l',ylim=rev(range(dp)))
>
>
> On Wed, Sep 23, 2009 at 7:58 AM, FMH  wrote:
>> Dear All,
>>
>> Let:
>> dp: depth of the river
>> tp: temperature with respect to depth
>>
>> We can have a simple scatter plot, between depth as y-axis and temperature 
>> as x-axis, by using a plot function as shown below.
>>
>> #
>> dp <- c(1,4,3,2,5,7,9,8,9,2)
>> tp <- 1:10
>> plot(tp,dp, type= 'l')
>> #
>>
>> Could someone advice me on the way to plot the same pair of observations, 
>> but with depth in descending order from the origin. Instead of depth, I 
>> tried to simply use rev(depth), but the result was bizarre.
>>
>> Thank you
>> Fir
>>
>>
>>
>>
>> __
>> 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.
>>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>
>
>
>
> __
> 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] Problem in graph plotting

2009-09-23 Thread FMH
Thank you for the code. I found that the coding does not work if there is an NA 
in dp variable. For instance;

#
dp <- c(1,4,NA,2,5,7,9,8,9,2)
tp <- 1:10
plot(tp,dp, type= 'l',ylim=rev(range(dp)))
 #

If this is the case, how could we rewrite the coding?

Thank you
Fir

 


- Original Message 
From: jim holtman 
To: FMH 
Cc: r-help@r-project.org
Sent: Wednesday, September 23, 2009 1:04:21 PM
Subject: Re: [R] Problem in graph plotting

try this:

plot(tp,dp, type= 'l',ylim=rev(range(dp)))


On Wed, Sep 23, 2009 at 7:58 AM, FMH  wrote:
> Dear All,
>
> Let:
> dp: depth of the river
> tp: temperature with respect to depth
>
> We can have a simple scatter plot, between depth as y-axis and temperature as 
> x-axis, by using a plot function as shown below.
>
> #
> dp <- c(1,4,3,2,5,7,9,8,9,2)
> tp <- 1:10
> plot(tp,dp, type= 'l')
> #
>
> Could someone advice me on the way to plot the same pair of observations, but 
> with depth in descending order from the origin. Instead of depth, I tried to 
> simply use rev(depth), but the result was bizarre.
>
> Thank you
> Fir
>
>
>
>
> __
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




__
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] Problem in graph plotting

2009-09-23 Thread baptiste auguie
Hi,

It's trivial with ggplot2,

library(ggplot2)
qplot(tp,dp, geom="line") + scale_y_reverse()

HTH,

baptiste

2009/9/23 David Winsemius :
>
> On Sep 23, 2009, at 7:58 AM, FMH wrote:
>
>> Dear All,
>>
>> Let:
>> dp: depth of the river
>> tp: temperature with respect to depth
>>
>> We can have a simple scatter plot, between depth as y-axis and temperature
>> as x-axis, by using a plot function as shown below.
>>
>> #
>> dp <- c(1,4,3,2,5,7,9,8,9,2)
>> tp <- 1:10
>> plot(tp,dp, type= 'l')
>> #
>
> Perhaps:
>
> dp <- c(1,4,3,2,5,7,9,8,9,2)
> tp <- 1:10
> plot(tp, -dp, type= 'l')
>
>>
>> Could someone advice me on the way to plot the same pair of observations,
>> but with depth in descending order from the origin. Instead of depth, I
>> tried to simply use rev(depth), but the result was bizarre.
>>
>> Thank you
>> Fir
>>
>
>
> David Winsemius, MD
> Heritage Laboratories
> 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.
>

__
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] Problem in graph plotting

2009-09-23 Thread Jim Lemon

On 09/23/2009 09:58 PM, FMH wrote:

Dear All,

Let:
dp: depth of the river
tp: temperature with respect to depth

We can have a simple scatter plot, between depth as y-axis and temperature as 
x-axis, by using a plot function as shown below.

# 
dp<- c(1,4,3,2,5,7,9,8,9,2)

tp<- 1:10
plot(tp,dp, type= 'l')
#
  
Could someone advice me on the way to plot the same pair of observations, but with depth in descending order from the origin. Instead of depth, I tried to simply use rev(depth), but the result was bizarre.


   

Hi Fir,
I think what you mean is this:

depth.order<-order(dp)
plot(dp[depth.order],tp[depth.order],
 main="Temperature by depth")

This lines up your depths on the x axis in descending order and displays 
the associated temperatures on the y axis.


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] Problem in graph plotting

2009-09-23 Thread David Winsemius


On Sep 23, 2009, at 7:58 AM, FMH wrote:


Dear All,

Let:
dp: depth of the river
tp: temperature with respect to depth

We can have a simple scatter plot, between depth as y-axis and  
temperature as x-axis, by using a plot function as shown below.


#
dp <- c(1,4,3,2,5,7,9,8,9,2)
tp <- 1:10
plot(tp,dp, type= 'l')
#


Perhaps:

dp <- c(1,4,3,2,5,7,9,8,9,2)
tp <- 1:10
plot(tp, -dp, type= 'l')



Could someone advice me on the way to plot the same pair of  
observations, but with depth in descending order from the origin.  
Instead of depth, I tried to simply use rev(depth), but the result  
was bizarre.


Thank you
Fir




David Winsemius, MD
Heritage Laboratories
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] Problem in graph plotting

2009-09-23 Thread jim holtman
try this:

 plot(tp,dp, type= 'l',ylim=rev(range(dp)))


On Wed, Sep 23, 2009 at 7:58 AM, FMH  wrote:
> Dear All,
>
> Let:
> dp: depth of the river
> tp: temperature with respect to depth
>
> We can have a simple scatter plot, between depth as y-axis and temperature as 
> x-axis, by using a plot function as shown below.
>
> #
> dp <- c(1,4,3,2,5,7,9,8,9,2)
> tp <- 1:10
> plot(tp,dp, type= 'l')
> #
>
> Could someone advice me on the way to plot the same pair of observations, but 
> with depth in descending order from the origin. Instead of depth, I tried to 
> simply use rev(depth), but the result was bizarre.
>
> Thank you
> Fir
>
>
>
>
> __
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

__
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] Problem in graph plotting

2009-09-23 Thread FMH
Dear All,

Let:
dp: depth of the river 
tp: temperature with respect to depth

We can have a simple scatter plot, between depth as y-axis and temperature as 
x-axis, by using a plot function as shown below.

# 
dp <- c(1,4,3,2,5,7,9,8,9,2)
tp <- 1:10
plot(tp,dp, type= 'l')
#
 
Could someone advice me on the way to plot the same pair of observations, but 
with depth in descending order from the origin. Instead of depth, I tried to 
simply use rev(depth), but the result was bizarre.
 
Thank you
Fir




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