[R] plots

David Stevens david.stevens at usu.edu
Fri Mar 14 23:57:31 CET 2014


Renalda - your figure got stripped out. I'll assume you mean to have 
depth on the vertical axis with a zero at the top and  increasing (+) 
depth as you go down. This is pretty simple to do.
1) use the (-) of depth on the y-axis
2) make the plot without the y-axis labels (yaxt='n')  using 
ylim=c(-(max(depth)),0)
3) add back an axis using the levels you want and (-) values
    axis(2,at=c(what you want, negative),labels=c(what you want, positive))
voila

e.g.
depth <- 1:10
density <- 2:11
plot(density,-depth,ylim=-rev(range(depth)),yaxt='n')
axis(2,-c(0,2,4,6,8,10),labels=c(0,2,4,6,8,10) )# if you want labels at 
0,2,4,6,8,10

David Stevens

Good luck
On 3/14/2014 1:55 AM, Renalda Munubi-Misinzo wrote:
> I would like to have a  plot with values in a reversed order (as shown in
> fig 2).  I tried to plot the graph in R using the following codes
>
> plot(density,depth,pch=as.numeric(species),xlab="fish density
> (#/m2)",ylab="water depth (m)")
>
> legend(locator(n=1),legend=c("Tropheus brichardi","Petrochromis
> kazumbe"),pch=1:2)
> unfortunately I can not reverse the axis to get a plot like the one shown
> in fig.2 Please can you help me with the codes?
>
> Thanks you
> Renny
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.

-- 
David K Stevens, P.E., Ph.D.
Professor and Head, Environmental Engineering
Civil and Environmental Engineering
Utah Water Research Laboratory
8200 Old Main Hill
Logan, UT  84322-8200
435 797 3229 - voice
435 797 1363 - fax
david.stevens at usu.edu




More information about the R-help mailing list