Re: [R] ylim problem in barplot

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Fri 06 Jan 2006 - 22:34:38 EST

>>>>> "Ben" == Ben Bolker <bolker@ufl.edu> >>>>> on Thu, 5 Jan 2006 19:21:48 +0000 (UTC) writes:

    Ben> Robert Baer <rbaer <at> atsu.edu> writes:
>> Well, consider this example:
>> barplot(c(-200,300,-250,350),ylim=c(-99,400))
>>
>> It seems that barplot uses ylim and pretty to decide things about the axis
>> but does some slightly unexpected things with the bars themselves that are
>> not just at the 'zero' end of the bar.
>>
>> Rob

no, there's no pretty() involved.
Maybe it helps you to just type box()
after the plot. Simply, the usual par("mar") margins are set.

I think ___in conclusion___ that Marc Schwartz' solution has been right on target all along:

>>>> Use 'xpd = FALSE' if you set 'ylim' because otherwise, the >>>> result may be confusing.

The real "problem" of barplot.default() is the fact that 'xpd = TRUE' is the default, and AFAIK that's not the case for other high-level plot functions.

One could debate if the default setting for xpd should not be changed to   

   xpd = (is.null(ylim) && !horiz) || (is.null(xlim) && horiz)

Now this has definitely gotten a topic for R-devel, and not R-help anymore.

    Ben> in previous cases I think there was room for debate about
    Ben> the appropriate behavior.  What do you think should happen
    Ben> in this case?  Cutting off the bars seems like the right thing
    Ben> to do; 

    Ben> is your point that the axis being confined to positive values (a side effect of setting ylim) is weird?

    Ben> Ben



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 22:42:45 2006

This archive was generated by hypermail 2.1.8 : Sat 07 Jan 2006 - 02:06:51 EST