[R] (no subject)
Fino Fontana
finofontana at yahoo.com
Sun Apr 15 22:18:22 CEST 2012
Thanks David, for helping out. Works great. A question about your added lines of code:
with opar <- par(mar=c(8,3,2,2)) your are setting the margins, and you store them in opar
next, par(opar) does nothing, I think because it just sets the same margins again.
shouldn't this be something like the following:
opar <- par( 'all graphics parameter') # store all current graphic parameters (in correct R language of course)
par(mar=c(8,3,2,2) # set new margins
barplot(...)
par(opar) # restore former graphics parameters.
Regards,
Fino
----- Original Message -----
From: David Winsemius <dwinsemius at comcast.net>
To: David Winsemius <dwinsemius at comcast.net>
Cc: Fino Fontana <finofontana at yahoo.com>; "r-help at r-project.org" <r-help at r-project.org>
Sent: Sunday, April 15, 2012 3:23 AM
Subject: Re: [R] (no subject)
On Apr 14, 2012, at 9:21 PM, David Winsemius wrote:
>
> 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) )
Make that:
> opar <- par(mar=c(8,3,2,2))
> barplot(times$duur, names.arg= times$taak, las=3 )
> par(opar)
>
> 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
>
> ______________________________________________
> 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