Kim Milferstedt
2007-Apr-04 17:17 UTC
[R] rgl.postscript generating pdf: floating xlab, font size, transparency
Hello, I very much enjoy rgl! But when converting the screen output to pdf using rgl.postscript I have encountered three problems: (1) I don't seem to have control over font sizes and point sizes (of added points) in the pdf output. I tried cex from "plot" but that does not have an effect. Initially I got some plots where fonts and especially points were far too small. But now I cannot reproduce this any more and fonts and axis are way too thick. How do you control font size, point size etc in the pdf output of rgl.postscript? (2) I could not figure out if it is possible to prevent the expressions entered for xlab, ylab and zlab to float around in the plot. I would like them aligned with the labeled axis if that's possible. Can I do that with rgl? (3) I would also like to add a transparent sphere to some plots. I did this by adding the next two lines to a plot. However, by adding rgl.material(), also my next plots have the new updated properties I only intended for the sphere. How can I re-set the rgl.material to their defaults or how can I assign properties only for one object? rgl.material(alpha = 0.2 ) spheres3d(0,0,0,1, col= "yellow") I am working under Win XP with R 2.4.1 and the most current version of rgl. Thanks, Kim ## Generating data-set X <- c(1:6) endpoint <- 4 interval <- 1 data.length <- 1200 data.rep <- 10 R <- rep(seq(1,endpoint, by =interval),rep((data.length/3)/endpoint,endpoint)) Q <- cbind(matrix(sample(X,data.length , replace = T), ncol = 3, byrow = T),R) ## plotting using rgl symbol.col <- c("blue", "orange", "gold", "indianred") plot.lim <- c(1, 6) plot3d( 0, 0, 0, xlim = plot.lim, ylim = plot.lim, zlim = plot.lim, type = "n", xlab = "X-Axis", ylab = "Y-Axis", zlab = "Z-Axis", ) for (l in 1:endpoint) { points3d( Q[,1][Q[,4] == l], Q[,2][Q[,4] == l], Q[,3][Q[,4] == l], col = symbol.col[l], size = 6) } rgl.postscript("D:/Kim/070402/test4.pdf", fmt="pdf" ) __________________________________________ Kim Milferstedt University of Illinois at Urbana-Champaign Department of Civil and Environmental Engineering 4125 Newmark Civil Engineering Laboratory 205 North Mathews Avenue MC-250 Urbana, IL 61801 USA phone: (001) 217 333-9663 fax: (001) 217 333-6968 email: milferst at uiuc.edu http://cee.uiuc.edu/research/morgenroth
Duncan Murdoch
2007-Apr-04 18:11 UTC
[R] rgl.postscript generating pdf: floating xlab, font size, transparency
On 4/4/2007 1:17 PM, Kim Milferstedt wrote:> Hello, > > I very much enjoy rgl! But when converting the screen output to pdf > using rgl.postscript I have encountered three problems: > > (1) I don't seem to have control over font sizes and point sizes (of > added points) in the pdf output. I tried cex from "plot" but that > does not have an effect. Initially I got some plots where fonts and > especially points were far too small. But now I cannot reproduce this > any more and fonts and axis are way too thick. How do you control > font size, point size etc in the pdf output of rgl.postscript?At the moment you don't, or you recompile from source with different choices. This is on the todo list.> (2) I could not figure out if it is possible to prevent the > expressions entered for xlab, ylab and zlab to float around in the > plot. I would like them aligned with the labeled axis if that's > possible. Can I do that with rgl?I don't quite understand what you want (if you want them to be aligned with something that can move, don't they have to float around?), but at present text support is quite limited. As part of the same effort as above this will eventually change for the better.> (3) I would also like to add a transparent sphere to some plots. I > did this by adding the next two lines to a plot. However, by adding > rgl.material(), also my next plots have the new updated properties I > only intended for the sphere. How can I re-set the rgl.material to > their defaults or how can I assign properties only for one object? > > rgl.material(alpha = 0.2 ) > spheres3d(0,0,0,1, col= "yellow")The general rules are: rgl.* functions may make long lasting changes to material properties (but most of them over-ride those, so you don't notice). *3d functions preserve material properties. The interaction of these two rules mean it's usually a bad idea to mix the two kinds of calls. You can do what you want with spheres3d(0,0,0,1, col= "yellow", alpha = 0.2) and the alpha change will only last for the duration of the call.> > I am working under Win XP with R 2.4.1 and the most current version of rgl.You can get one slightly more current than the most current release from my web page, <http://www.stats.uwo.ca/faculty/murdoch/software>. It has the following changes, which may impact you: v0.70.570 - changes to configure script from Laszlo Kajan and Brian Ripley: should now be much more portable - removed deprecated OSX font setting calls - texture properties are now returned by material3d() - allowed normals and texture coordinates to be specified in triangles and quads - normals may be specified in qmesh objects, but (at present) subdivide removes them - material3d() now preserves the values of unspecified parameters (as documented, but not previously functioning) - clear3d() can now reset material properties to the defaults, and open3d() does this. - minor fix for gcc 4.3 compatibility Duncan Murdoch> > Thanks, > > Kim > > ## Generating data-set > X <- c(1:6) > endpoint <- 4 > interval <- 1 > data.length <- 1200 > data.rep <- 10 > > R <- rep(seq(1,endpoint, by =interval),rep((data.length/3)/endpoint,endpoint)) > Q <- cbind(matrix(sample(X,data.length , replace = T), ncol = 3, byrow = T),R) > > ## plotting using rgl > symbol.col <- c("blue", "orange", "gold", "indianred") > plot.lim <- c(1, 6) > plot3d( 0, > 0, > 0, > xlim = plot.lim, > ylim = plot.lim, > zlim = plot.lim, > type = "n", > xlab = "X-Axis", > ylab = "Y-Axis", > zlab = "Z-Axis", > ) > for (l in 1:endpoint) > { > points3d( Q[,1][Q[,4] == l], > Q[,2][Q[,4] == l], > Q[,3][Q[,4] == l], > col = symbol.col[l], > size = 6) > } > > rgl.postscript("D:/Kim/070402/test4.pdf", fmt="pdf" ) > > __________________________________________ > > Kim Milferstedt > University of Illinois at Urbana-Champaign > Department of Civil and Environmental Engineering > 4125 Newmark Civil Engineering Laboratory > 205 North Mathews Avenue MC-250 > Urbana, IL 61801 > USA > phone: (001) 217 333-9663 > fax: (001) 217 333-6968 > email: milferst at uiuc.edu > http://cee.uiuc.edu/research/morgenroth > > ______________________________________________ > R-help at 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 > and provide commented, minimal, self-contained, reproducible code.