[R] 3d plotting alternatives. I like persp, but regret the lack of plotmath.
David Winsemius
dwinsemius at comcast.net
Thu Dec 29 20:04:23 CET 2011
I'm not sure it is entirely responsive to the request, but I did hash
out a way to add axis labels to car::scatter3d plots. There a worked
example on SO:
http://stackoverflow.com/questions/8204972/carscatter3d-in-r-labeling-axis-better/8206320#8206320
The SO screenshot won't show that fact that the labels will
appropriately twirl in 3 space in an RGL window. If you want the full
code, then Ben Bolker has put it on his website which he referenced in
a follow-up question:
http://stackoverflow.com/questions/8231007/having-trouble-executing-the-edits-to-scatter3d-default/
library(car)
source(url("http://www.math.mcmaster.ca/bolker/R/misc/scatter3d.R"))
scatter3d(prestige ~ income + education, data=Duncan)
--
David.
On Dec 29, 2011, at 1:01 PM, Paul Johnson wrote:
> I have been making simple functions to display regressions in a new
> package called "rockchalk". For 3d illustrations, my functions use
> persp, and I've grown to like working with it. As an example of the
> kind of things I like to do, you might consult my lecture on
> multicollinearity, which is by far the most detailed illustration I've
> prepared.
>
> http://pj.freefaculty.org/guides/stat/Regression/Multicollinearity/Multicollinearity-1-lecture.pdf
>
> I used persp mainly because I can understand it, and it can be made to
> work like plot in R, with additional tools like lines and points and
> such. I don't want to interact with these plots, I just need to put
> them into lectures & documents relatively easily. And I've also
> succeeded in turning them into flash video with R2SWF, which works
> great!
>
> Last summer, I put together some lecture notes illustrating persp,
> scatterplot3d, and persp3d.
> http://pj.freefaculty.org/guides/Rcourse/plot-3d/plots-3d.pdf. As I
> review that now, I see I did not make any progress on the lattice
> based plotters, or I did not write it down, anyway. scatterplot3d did
> almost everything I needed to do, but not everything, and so I used
> persp in my newer effort.
>
> Then I put some plot math in an axis label and ran into the problem
> that everybody else who uses persp finds, eventually. persp doesn't
> allow expressions in axis labels. From searching in r-help, I see
> that many people have run up against the same trouble. Most people say
> "too bad", I'll switch to some other tool.
>
>
> Suggested alternatives.
>
> 1. Use wireframe or cloud in lattice. They can handle plotmath.
>
> I've been studying that, and it can handle plot math, but I just can't
> get the kinds of graphs I want from it. In the persp framework, I can
> draw the 3d plot, and then add details to it one by one. I can
> comprehend the little steps. In wireframe and cloud, it *appears* to
> me i have to pack all of that work into one single command, and it is,
> well, either too difficult or impossible. Or perhaps I'm just not
> understanding the documentation. If I could make the sorts of plots I
> need with lattice tools, I would do it. But I'm really blocked at the
> front door by the "write one giant function call" nature of it.
>
> I realize that's vague because I have not told you specifically what I
> want to do. If there is a lattice expert reading, can you give me
> some HOWTO hints? Take, for example, Slide 19 in this one:
>
> http://pj.freefaculty.org/guides/stat/Regression/Multicollinearity/Multicollinearity-1-lecture.pdf
>
> gray dots in the x1-x2 plane, blue points hovering above, red pointed
> arrows from gray to blue.
>
> And then later on, say slide 36-60, I have regression planes drawn in
> with the arrows from the plane to the points.
>
>
> 2. Use rgl based tools. These ones are especially neat if you want to
> interact with the graph--"spin" a 3d graph or get a display with
> lively colors.
>
> It works more like plot, in the sense that you can draw the figure and
> then add components with points3d and so forth. And there are nice
> working examples of extensions in misc3d. And also, the R CMDR
> interface has a working pull down menu system that can make rgl 3d
> graphs. That's a big plus.
>
> After playing with some examples, I see these troubles. The only
> output device that runs well (finishes and does not generate massive
> files) is png. The output quality on the screen is quite beautiful,
> but transition to black-and-white is not as nice looking as persp, in
> my opinion. These graphs draw much more slowly. They are more
> difficult to script out in an Sweave document, it seems to me.
>
> If those criticisms are wrong, I would be glad to know.
>
> So I'm back wondering why persp can't be "updated".
>
> Nobody has explained why it is not possible to revise persp to allow
> expressions in axis labels. Perhaps nobody has done it because people
> think that persp has no fans :) But I'm a fan.
>
> --
> Paul E. Johnson
> Professor, Political Science
> 1541 Lilac Lane, Room 504
> University of Kansas
>
> ______________________________________________
> 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.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list