[R] (no subject)

David Winsemius dwinsemius at comcast.net
Sun Apr 15 03:21:14 CEST 2012


On Apr 14, 2012, at 8:11 PM, Fino Fontana wrote:

> I am wrestling with the following in creating a barplot in R:
> I have a data set with 18 entries. It is plotted in a bargraph. The  
> x-axis should have 18 tick marks each with its own label. What  
> happens is, only a few labels are shown; there is not enough space  
> for all labels. The tick marks are concentrated on the left side of  
> the axis.

The mar parameter to par() will give you control of the lower margin  
and the 'las' parameter will give you control of the axis label  
orientation:

barplot(times$duur, names.arg= times$taak, las=3, mar=c(8,3,2,2) )

I'd like to have all labels shown, in vertical direction.
>
> This is part of the data:
>
>> times
>         taak  duur
> 1   algemeen 48.75
> 2   swimming 14.25
> 3   football 24.25
> 4     tennis 36.75
> 5  bicycling  1.50
>
> Under 'taak' are the labels.
> This is the code that should do the job:
>
> barplot(
> width= bar_width,
> times$duur,
> names.arg=times$taak,
> col=fill_colors,
> border="NA",
> space=0.3,
> xlab="taak",
> ylab="uren",
> main="Uren per taak")
>
> axis(1,at=1:length(times$taak),lab=times$taak)
>
>
> Could anyone give me advise on how to get rid of this horrible x axis?
>
> Thanks and r
>
> ______________________________________________
> 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 Winsemius, MD
West Hartford, CT



More information about the R-help mailing list