Hello, I am very interested in "banking to 45 degrees" as defined by William S. Cleveland in "Visualizing Data." I like to do it in R as well as Excel, etc. With R I have come across the following method: xyplot(x, y, aspect="xy") (part of "lattice" package) which will bank my graph to 45 degrees. My question is how do I obtain the aspect ratio that banks this graph to 45 degrees? I understand that R does it for me, but I would like to explicitly know the aspect ratio so that I can configure other graphs in Excel or other software. aspect ratio = v / h (v is vertical distance of plot, h is horizontal distance of plot. NOT in the data units, but true, actual distance). I've also come across "banking ()", but I don't understand it, nor the significance of the value it returns. Regardless, it doesn't seem to be the aspect ratio that I am looking for. I'd appreciate any help. Thanks in advance! ~Josh _________________________________________________________________ Refresh_family_safety_052008 ______________________________________________ [hidden email] 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. |
On 5/20/08, Joshua Hertlein <[hidden email]> wrote:
> > Hello, > > I am very interested in "banking to 45 degrees" as defined by William S. Cleveland > in "Visualizing Data." I like to do it in R as well as Excel, etc. With R I have come > across the following method: > > xyplot(x, y, aspect="xy") (part of "lattice" package) > > which will bank my graph to 45 degrees. My question is how do I obtain the > aspect ratio that banks this graph to 45 degrees? I understand that R does it > for me, but I would like to explicitly know the aspect ratio so that I can configure > other graphs in Excel or other software. > foo <- xyplot(sunspot.year ~ 1700:1988, type = "l", aspect = "xy") > foo$aspect.ratio [1] 0.04554598 > aspect ratio = v / h (v is vertical distance of plot, h is horizontal distance of plot. > NOT in the data units, but true, actual distance). > > I've also come across "banking ()", but I don't understand it, nor the significance > of the value it returns. Regardless, it doesn't seem to be the aspect ratio that > I am looking for. banking(dx, dy) basically gives you the median of abs(dy/dx). The idea is that dx and dy define the slopes of the segments you want to bank (so typically, dx = diff(x) and dy = diff(y) if x and y are the data you want to plot). banking() gives you a single (summary) slope; you then choose the aspect ratio of your plot so that this slope (in the data coordinates) has a physical slope of 1. To do this, you solve an equation involving the data range in the x- and y-axes of your plot. -Deepayan ______________________________________________ [hidden email] 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. |
On May 20, 2008, at 2:34 PM, Deepayan Sarkar wrote:
> On 5/20/08, Joshua Hertlein <[hidden email]> wrote: >> >> Hello, >> >> I am very interested in "banking to 45 degrees" as defined by >> William S. Cleveland >> in "Visualizing Data." I like to do it in R as well as Excel, >> etc. With R I have come >> across the following method: >> >> xyplot(x, y, aspect="xy") (part of "lattice" package) >> >> which will bank my graph to 45 degrees. My question is how do I >> obtain the >> aspect ratio that banks this graph to 45 degrees? I understand >> that R does it >> for me, but I would like to explicitly know the aspect ratio so >> that I can configure >> other graphs in Excel or other software. > > >> foo <- xyplot(sunspot.year ~ 1700:1988, type = "l", aspect = "xy") >> foo$aspect.ratio > [1] 0.04554598 > > >> aspect ratio = v / h (v is vertical distance of plot, h is >> horizontal distance of plot. >> NOT in the data units, but true, actual distance). >> >> I've also come across "banking ()", but I don't understand it, >> nor the significance >> of the value it returns. Regardless, it doesn't seem to be the >> aspect ratio that >> I am looking for. > > banking(dx, dy) basically gives you the median of abs(dy/dx). The idea > is that dx and dy define the slopes of the segments you want to bank > (so typically, dx = diff(x) and dy = diff(y) if x and y are the data > you want to plot). banking() gives you a single (summary) slope; you > then choose the aspect ratio of your plot so that this slope (in the > data coordinates) has a physical slope of 1. To do this, you solve an > equation involving the data range in the x- and y-axes of your plot. 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. If a line has real (data) slope r, and the aspect ratio is b, then the line appears with slope rb. 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? > -Deepayan Haris Skiadas Department of Mathematics and Computer Science Hanover College ______________________________________________ [hidden email] 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. |
On 5/20/08, Charilaos Skiadas <[hidden email]> 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 ______________________________________________ [hidden email] 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. |
On May 20, 2008, at 5:59 PM, Deepayan Sarkar wrote:
> On 5/20/08, Charilaos Skiadas <[hidden email]> 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).] So in this case, the slope of the line y=x, which is 1, appears as 0.5. I effectively wanted to combine the two effects, of the sizes of the two scales and of the sizes of the window. They both have an effect on how a line of slope 1 is seen. But perhaps I am missing something here? >> 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). > > 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. That's a very good point, I never thought of it that way (though I have to say, I haven't seen anything but the arithmetic average used in getting "THE median" before). > I think it is unlikely that the difference in calculations > leads to any difference in the perceptual benefits. Agreed. > Of course, the current calculation has the advantage of doing one less > division! :-) For me, that's reason enough to keep it as is ;) > -Deepayan Haris Skiadas Department of Mathematics and Computer Science Hanover College ______________________________________________ [hidden email] 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. |
In reply to this post by Joshua Hertlein
> I've also come across "banking ()", but I don't understand it, nor the significance of the value it returns. Regardless, it doesn't seem to be the aspect ratio that I am looking for.
You might also want to have a look at: @article{heer:2006, Title = {Multi-scale banking to 45 degrees}, Author = {Heer, Jeffrey and Agrawala, Maneesh}, Journal = {IEEE Transactions on Visualization and Computer Graphics}, Number = {5}, Url = {http://vis.berkeley.edu/papers/banking/}, Volume = {12}, Year = {2006} } It's a rather nice extension. Hadley -- http://had.co.nz/ ______________________________________________ [hidden email] 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. |
Free forum by Nabble - Free Resume Builder | Edit this page |