On 05/23/2012 09:34 PM, bets wrote:
Hey,

I am trying to create barplot of abundances over time (in days). The period
is over 171 days, so I don't want to have all labels there but only the
first day of the month. I couldn't find anything like this on the forum yet.
Mostrly it's about year to year data.

This is the relevant part of my table:

datum   month   abundance
26/03/11         March  1
27/03/11         March  0
28/03/11         March  1
29/03/11         March  0
30/03/11         March  0
31/03/11         March  0
1/04/11  April  0
2/04/11  April  0
3/04/11  April  0
...
9/09/11 September 1

I tried making a sequence:
hatch$axis.ticks2=seq(from=hatch$datum[1],to=hatch$datum[171], by=30)
But this sequence is too short to use the names.arg function.
Next, I tried more ideas from this forum that might work. But the best I got
was by just replacing the day by a month and reducing the size of the
tickmarks. Or by blanking excessive labels in R commander. But this is
really poor substitute of what I actually want. Furthermore, in the end I
want the labels vertical to match other graphs (las=2), but when doing that
my labels become so dense it's basically one black blur.

bar=barplot(abundance, col="black",xlab="", ylim=c(0,120), axisnames=T,
ylab="Total fish",axis.lty=1)
axis(1,at=bar, tcl=-0.01, las=1,lab=hatch$month,cex.axis=0.8)

Hi bets,
So you have 171 bars with most of them 0? If you want to use "barplot", drop the x axis:

barplot(...,xaxt="n",...)

and then display an x axis with, let's see, seven labels. Something like:

axis(1,at=seq(as.Date("2011-03-15"),as.Date("2011-09-09"),by=30),
 labels=month.abbr[3:9])

If they don't all display, try "staxlab" in the plotrix package.

Jim

______________________________________________
R-help@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.

Reply via email to