Re: [R] ylim problem in barplot

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Fri 06 Jan 2006 - 01:11:08 EST

>>>>> "PaulB" == Bliese, Paul D LTC USAMH <paul.bliese@us.army.mil> >>>>> on Thu, 5 Jan 2006 14:01:17 +0100 writes:

    PaulB> R Version 2.2.0
    PaulB> Platform: Windows  

    PaulB> When I use barplot but select a ylim value greater
    PaulB> than zero, the graph is distorted.  The bars extend
    PaulB> below the bottom of the graph.

Well, my question would be if that is not a feature :-) Many people would consider barplots that do not start at 0 as  "Cheating with Graphics" (in the vein of "Lying with Statistics").  

    PaulB> For instance the command produces a problematic graph.

    PaulB> barplot(c(200,300,250,350),ylim=c(150,400))

The advantage of the current graphic drawn is that everyone *sees* that the bars were cut off {and that one should really think twice before producing such cheating graphics.. :-)}

 plot(c(200,300,250,350), ylim=c(150,400), type = "h",

      lwd=20, xaxt="n", col="gray")

produces something closer to what you like. [yes, you can get rid of the roundedness of the thick-line ends;
--> ?par and look for 'lend';
--> op <- par(lend = 1) ; plot(.........) ; par(op)
 In R-devel (i.e. from R 2.3.0 on) you can even say   plot(c(200,300,250,350), ylim=c(150,400), type = "h",

       lwd=20, xaxt="n", col="gray", lend = 1) ]

But after all, I tend to agree that R should behave a bit differently here,
e.g., first giving a warning about the non-approriate ylim but then still obey the ylim specification more nicely.

Regards,
Martin Maechler



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jan 06 01:27:54 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:51 EST