[R] Barplot -density and multhist x-axis problem

Honorata Kaja Gajda honorata.gajda at student.umb.no
Wed Mar 11 08:50:30 CET 2009


Thanks in advance for any help

I would like to plot a barplot with probability density instead of count
frequencies, as is possible in histograms (freq=FALSE). Is this possible?
I have tried the following code:

with(center,table(light))->light.table
barplot(light.table ,col=brewer, freq=FALSE, beside=T)

But  freq=FALSE doesn’t seem to work in the command of barplot.
The reason why I want to use a barplot is that I have two variables. I
have tried to use multhist instead, but when I plot the histogram the
x-axis labels are unevenly spaced. I would like to create a bar with 7
ticks on the x-axis (1,2,3..7), however the following tics are yielded in
the x-axis (1, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5). How can I regulate this?
I have used the following code:

l<-list(m1=(center$light[center$site=="1"]),
m2=(center$light[center$site=="2"]))
multhist(l,breaks=c(1:7, by=1), freq=FALSE, main="Illumination in Plot
Center", ylab="Density", col =brewer)

I have tried names.arg= but this doesn’t work in multihist either.
Is there any way around this problem? Either by using barplot or multihist?

I am very grateful for any help
Honorata




More information about the R-help mailing list