[R] column and line graphs in R

Jim Lemon jim at bitwrit.com.au
Fri Mar 15 13:36:20 CET 2013


On 03/15/2013 01:40 AM, Gian Maria Niccolò Benucci wrote:
> Hi again,
>
> Thank you all for your support. I would love to have a graph in which two
> variables are contemporary showed. For example a histogram and a curve
> should be the perfect choice. I tried to use twoord.plot() but I am not
> sure I understand how to manage the the arguments lx, ly, rx, ry... Anyway
> these are my data:
>
>> nat_af
>         rel.abund rel.freq
> MOTU2      0.003    0.083
> MOTU4      0.029    0.167
> MOTU6      0.033    0.167
> MOTU7      0.023    0.083
> MOTU9      0.009    0.083
> MOTU11     0.042    0.250
> MOTU14     0.069    0.083
> MOTU16     0.059    0.167
> MOTU17     0.034    0.083
> MOTU18     0.049    0.083
> MOTU19     0.084    0.333
> MOTU20     0.015    0.083
> MOTU21     0.059    0.083
> MOTU22     0.032    0.167
> MOTU23     0.142    0.250
> MOTU24     0.031    0.083
> MOTU25     0.034    0.083
> MOTU29     0.010    0.083
> MOTU30     0.011    0.083
> MOTU33     0.004    0.083
> MOTU36     0.034    0.333
> MOTU34     0.182    0.417
>
> First column is the relative abundance of the given MOTU and second column
> is the relative frequency of the same MOTU.

Hi Gian,
You can do this in twoord.plot like this (data is named "nat_af" and the 
first column is labeled "label"):

twoord.plot(1:22-0.2,nat_af$rel.abund,1:22+0.2,nat_af$rel.freq,
  type=c("bar","bar"),lylim=c(0,0.19),rylim=c(0,0.43),halfwidth=0.2,
  main="Abundance and frequency",ylab="Abundance",rylab="Frequency",
  xticklab=rep("",22))
staxlab(1,at=1:22,labels=nat_af$label,cex=0.8,srt=45)

Jim



More information about the R-help mailing list