[R] vertically aligned X axis labels disappear off R Graphics window

Paul Johnson pauljohn32 at gmail.com
Tue Mar 3 08:41:00 CET 2009


On Wed, Feb 25, 2009 at 12:51 PM, Uwe Ligges
<ligges at statistik.tu-dortmund.de> wrote:
>
>
> R User R User wrote:
>>
>> Hi guys,
>> I'm evaluating R for basic data exploration. I produce a bar plot of the
>> data, with the x axis labels aligned vertically. However, the start of
>> labels longer than about 10 characters are cut off by the bottom of the
>> graphics window.
>>

Been there, did that :)

Run these steps. Run the par with various values to change margins.

The size of the figure is fixed from the outside edges, so when you
make the margin bigger, the drawing gets squeezed.

x <- rpois(14, lambda=10)

mynames <- c("Really Long Name","Really Long Name","Really Long
Name","Really Long Name","Really Long Name","Really Long Name","Really
Long Name","Really Long Name","Really Long Name","Really Long
Name","Really Long Name","Really Long Name","Really Long Name","Really
Long Name Long Long")


barplot(x, names=mynames, las=2)


## RSiteSearch("barplot names margins")

barplot(x, names=abbreviate(mynames), las=2)

par(mar=c(9.5,3,0.5, 0.3))
barplot(x, names=mynames, las=2)


## believe should be same as following, but the following works
## to change the margin only once, and further calls
## to similar have no margin changing effect. So
## you need run par over again before boxplotting.

barplot(x, names=mynames, las=2, mar=c(9.5,3,0.5, 0.3))


-- 
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas




More information about the R-help mailing list