Discussion:
[R] [R ]Exporting rgl.snapshot and rgl.postscript
Thanh Tran
2018-11-27 12:53:38 UTC
Permalink
Dear all,



I'm trying to plot a surface over the x-y plane. In my data, the response
is KIC, and 4 factors are AC, AV, T, and Temp. I want to have response
surface of KIC with two factors, i.e., AC and AV. A typical second-degree
data<-read.csv("2.csv", header =T)
mod <- lm(KIC~AC+I(AC^2)+AV+I(AV^2)+T+I(T^2)+Temp+I(Temp^2)+AC:AV+AC:T+AC:Temp+AV:T+AV:Temp+T:Temp,
+ data = data)
library(rgl)
KIC <- function(AC, AV, Temp, T) predict(mod, newdata = data.frame(AC, AV, Temp, T))
persp3d(KIC, xlim = c(4, 5), # The range of values for AC
+ ylim = c(4, 7), # The range for AV

+ xlab = "AC", ylab = "AV", zlab = "KIC",

+ col = "lightblue",

+ otherargs = list(Temp = 15, T = 40))
rgl.snapshot("1.png", fmt = "png", top = TRUE )
rgl.postscript("1.pdf","pdf")
The problem is that the figure created by *rgl.snapshot* (attached Figure
1) has low quality, while the figure created by *rgl.postscript* (attached
Figure 2) doesn’t have adequate details.



Can somebody please show me how to properly export the file? I would prefer
the Figure have the TIFF or PDF with the resolution 600 dpi. I really
appreciate your support and help.



Best regards,

Nhat Tran



Ps: I also added a CSV file for practicing R.
______________________________________________
R-***@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.
Duncan Murdoch
2018-11-27 14:06:50 UTC
Permalink
Post by Thanh Tran
Dear all,
I'm trying to plot a surface over the x-y plane. In my data, the response
is KIC, and 4 factors are AC, AV, T, and Temp. I want to have response
surface of KIC with two factors, i.e., AC and AV. A typical second-degree
data<-read.csv("2.csv", header =T)
mod <- lm(KIC~AC+I(AC^2)+AV+I(AV^2)+T+I(T^2)+Temp+I(Temp^2)+AC:AV+AC:T+AC:Temp+AV:T+AV:Temp+T:Temp,
+ data = data)
library(rgl)
KIC <- function(AC, AV, Temp, T) predict(mod, newdata = data.frame(AC, AV, Temp, T))
persp3d(KIC, xlim = c(4, 5), # The range of values for AC
+ ylim = c(4, 7), # The range for AV
+ xlab = "AC", ylab = "AV", zlab = "KIC",
+ col = "lightblue",
+ otherargs = list(Temp = 15, T = 40))
rgl.snapshot("1.png", fmt = "png", top = TRUE )
rgl.postscript("1.pdf","pdf")
The problem is that the figure created by *rgl.snapshot* (attached Figure
1) has low quality, while the figure created by *rgl.postscript* (attached
Figure 2) doesn’t have adequate details.
You can improve the rgl.snapshot output by starting from a large window.
You can do this either by using the mouse to enlarge the window, or
specifying values for windowRect in par3d() or open3d(), e.g.

open3d(windowRect=c(0,0, 1800, 1800))

Whether very large values will be respected depends on the system. For
example, my Macbook Air reduces that request so the whole window is visible,
Post by Thanh Tran
par3d("windowRect")
[1] 0 45 1440 901

You can set the default to be a large window using

r3dDefaults <- getr3dDefaults()
r3dDefaults$windowRect <- c(0,0, 1800, 1800)

(This will only be respected by the *3d functions like open3d(), not the
low-level rgl.* functions like rgl.open().)

The rgl.postscript() display is limited by what the GL2PS library can
do, so if it doesn't do what you want, there's not much you can do to
improve it.

Duncan Murdoch
Post by Thanh Tran
Can somebody please show me how to properly export the file? I would prefer
the Figure have the TIFF or PDF with the resolution 600 dpi. I really
appreciate your support and help.
Best regards,
Nhat Tran
Ps: I also added a CSV file for practicing R.
______________________________________________
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.
______________________________________________
R-***@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.
Thanh Tran
2018-11-27 23:40:37 UTC
Permalink
Hi Duncan Murdoch
Thank you for your support.
Best regards,
Nhat Tran

Vào Th 3, 27 thg 11, 2018 vào lúc 23:06 Duncan Murdoch <
Post by Thanh Tran
Dear all,
I'm trying to plot a surface over the x-y plane. In my data, the response
is KIC, and 4 factors are AC, AV, T, and Temp. I want to have response
surface of KIC with two factors, i.e., AC and AV. A typical second-degree
data<-read.csv("2.csv", header =T)
mod <-
lm(KIC~AC+I(AC^2)+AV+I(AV^2)+T+I(T^2)+Temp+I(Temp^2)+AC:AV+AC:T+AC:Temp+AV:T+AV:Temp+T:Temp,
Post by Thanh Tran
+ data = data)
library(rgl)
KIC <- function(AC, AV, Temp, T) predict(mod, newdata = data.frame(AC,
AV, Temp, T))
Post by Thanh Tran
persp3d(KIC, xlim = c(4, 5), # The range of values for AC
+ ylim = c(4, 7), # The range for AV
+ xlab = "AC", ylab = "AV", zlab = "KIC",
+ col = "lightblue",
+ otherargs = list(Temp = 15, T = 40))
rgl.snapshot("1.png", fmt = "png", top = TRUE )
rgl.postscript("1.pdf","pdf")
The problem is that the figure created by *rgl.snapshot* (attached Figure
1) has low quality, while the figure created by *rgl.postscript*
(attached
Post by Thanh Tran
Figure 2) doesn’t have adequate details.
You can improve the rgl.snapshot output by starting from a large window.
You can do this either by using the mouse to enlarge the window, or
specifying values for windowRect in par3d() or open3d(), e.g.
open3d(windowRect=c(0,0, 1800, 1800))
Whether very large values will be respected depends on the system. For
example, my Macbook Air reduces that request so the whole window is visible,
Post by Thanh Tran
par3d("windowRect")
[1] 0 45 1440 901
You can set the default to be a large window using
r3dDefaults <- getr3dDefaults()
r3dDefaults$windowRect <- c(0,0, 1800, 1800)
(This will only be respected by the *3d functions like open3d(), not the
low-level rgl.* functions like rgl.open().)
The rgl.postscript() display is limited by what the GL2PS library can
do, so if it doesn't do what you want, there's not much you can do to
improve it.
Duncan Murdoch
Post by Thanh Tran
Can somebody please show me how to properly export the file? I would
prefer
Post by Thanh Tran
the Figure have the TIFF or PDF with the resolution 600 dpi. I really
appreciate your support and help.
Best regards,
Nhat Tran
Ps: I also added a CSV file for practicing R.
______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
Post by Thanh Tran
and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]

______________________________________________
R-***@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.
Loading...