[R] column and line graphs in R

Marc Girondot marc_grt at yahoo.fr
Fri Mar 15 07:17:53 CET 2013


When you send data, use dput() to send them. It is much more easy for 
people who want to help you.
Here is an example. I am not sure if it is what you want but you can 
play with the code.
Sincerely

Marc

fungal <- structure(list(rel.abund = c(0.003, 0.029, 0.033, 0.023, 0.009,
0.042, 0.069, 0.059, 0.034, 0.049, 0.084, 0.015, 0.059, 0.032,
0.142, 0.031, 0.034, 0.01, 0.011, 0.004, 0.034, 0.182), rel.freq = c(0.083,
0.167, 0.167, 0.083, 0.083, 0.25, 0.083, 0.167, 0.083, 0.083,
0.333, 0.083, 0.083, 0.167, 0.25, 0.083, 0.083, 0.083, 0.083,
0.083, 0.333, 0.417)), .Names = c("rel.abund", "rel.freq"),
class = "data.frame", row.names = c("MOTU2",
"MOTU4", "MOTU6", "MOTU7", "MOTU9", "MOTU11", "MOTU14", "MOTU16",
"MOTU17", "MOTU18", "MOTU19", "MOTU20", "MOTU21", "MOTU22", "MOTU23",
"MOTU24", "MOTU25", "MOTU29", "MOTU30", "MOTU33", "MOTU36", "MOTU34"
))

premar <- par("mar")
par(mar=c(5,4,4,4)+0.1)

plot(fungal[,1], type="h", lwd=20, lend=2, bty="n", xlab="", 
ylab="Relative abundance", xaxt="n", ylim=c(0,0.2))
par(xpd=TRUE)
segments(-2.5, 0.01, -2.5, 0.03, lwd=20, lend=2, col="black")

par(new=TRUE)
plot(fungal[,2], type="p", bty="n", pch=16, col="red", axes=FALSE, 
xlab="", ylab="", main="", ylim=c(0,0.5))
axis(1, at=1:length(rownames(fungal)), labels=rownames(fungal), las=2)
axis(4)
mtext("Relative frequency", side=4, line=3)
points(25.6, 0.1, pch=16, col="red")

par(mar=premar)


Le 14/03/13 15:40, Gian Maria Niccolò Benucci a écrit :
> 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.
> Thank you very much in advance,
>


-- 
__________________________________________________________
Marc Girondot, Pr

Laboratoire Ecologie, Systématique et Evolution
Equipe de Conservation des Populations et des Communautés
CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079
Bâtiment 362
91405 Orsay Cedex, France

Tel:  33 1 (0)1.69.15.72.30   Fax: 33 1 (0)1.69.15.73.53
e-mail: marc.girondot at u-psud.fr
Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html
Skype: girondot



More information about the R-help mailing list