[R] Problem in graph plotting
    Jim Lemon 
    jim at bitwrit.com.au
       
    Wed Sep 23 14:34:22 CEST 2009
    
    
  
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
    
    
More information about the R-help
mailing list