Re: [R] Question about banking to 45 degrees.

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Tue, 20 May 2008 14:59:27 -0700

On 5/20/08, Charilaos Skiadas <cskiadas_at_gmail.com> wrote:

> Here is how I see it. Let me define a "visual y-unit" as the height of a
> unit of data in the y-direction, and similarly for a visual x-unit.
> Then the aspect ratio is the quotient of the visual y-unit over the visual
> x-unit. So the aspect ratio is the number of visual x-units that have the
> same length as one visual y-unit.

[Not that it matters, but it is not clear what you mean here. Let's say we have a 100cm x 100cm plot, with data ranges xlim=c(0, 100) and ylim=c(0, 200). Then, the aspect ratio is 1, your "visual y-unit" is 0.5cm, and "visual x-unit" is 1cm (so their ratio is 0.5).]

> If a line has real (data) slope r, and the aspect ratio is b, then the line
> appears with slope rb.

Agreed.

> Now, there are two things one can compute (for simplicity I assume all
> slopes are positive, insert absolute values as necessary):
> 1. The value of the aspect ratio, that makes the median of the visual
> slopes be 1. This would be obtained by requiring the median of all the rb to
> be 1, which means that the aspect ratio would be 1/median(slopes).
> 2. The median of the aspect ratios, that make each individual line have
> slope 1. So for each line with slope r, we consider the aspect ratio 1/r,
> and then take the median of that. So this would be median(1/slopes).
>
> Now, unless I am missing something, the banking function computes the
> second one of these, while I think the documentation (and my intuition) say
> that we want the first of these. In the case where there is an odd number of
> data, they would agree, but otherwise one is related to the arithmetic mean
> of the two middle observations, while the other is referring to the harmonic
> mean of the two observations. Those will likely be close to each other in
> most cases, so perhaps this is a moot point in practice, but am I wrong in
> thinking that 1/median(abs(dy[id]/dx[id])) would be the right thing to have
> in the code to the banking function?

I agree with your analysis, but would claim that both calculations are "right", since the median of 2 numbers is formally any number in between. I think it is unlikely that the difference in calculations leads to any difference in the perceptual benefits.

Of course, the current calculation has the advantage of doing one less division! :-)

-Deepayan



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. Received on Tue 20 May 2008 - 22:04:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 20 May 2008 - 23:30:39 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive