Re: [R] Save a graph file use jpeg(file=file)

2022-01-05 Thread Sorkin, John
Ducan,

As always, you are very giving of your time to help R users. Thank you!

scatter3d is from the car package.

As I understand snapshot3d, it takes a screen shot and saves the resultant 
file. This implies that the resultant file will be 72 DPI. I need to get a 
higher resolution image, at least 300 DPI. Do you have any suggestions?

Thanks as always.

John


From: Duncan Murdoch 
Sent: Wednesday, January 5, 2022 2:58 PM
To: Sorkin, John; r-help@r-project.org (r-help@r-project.org)
Subject: Re: [R] Save a graph file use jpeg(file=file)

On 05/01/2022 2:45 p.m., Sorkin, John wrote:
> I am trying to create a 3-D graph (using scatter3d) and save the graph to a 
> file so I can insert the graph into a manuscript. I am able to create the 
> graph. When I run the code below an RGL window opens that has the graph. The 
> file is saved to disk after dev.odd() runs. Unfortunately, when I open the 
> saved file, all I see is a white window. Can someone tell me how to have the 
> file so I can subsequently read and place the file in a paper? The problem 
> occurs regardless of the format in which I try to save the file, e.g. png, 
> tiff.
>
>
> x <- 1:10
> y <- 2:11
> z <- y+rnorm(10)
> ForGraph<-data.frame(x=x,y=y,z=z)
> ForGraph
>
> gpathj <- file.path("C:","LAL","test.jpeg")
> gpathj
> jpeg(file = gpathj)
> par(mai = c(0.5, 0.5, 0.5, 0.5))
> scatter3d(z=ForGraph$x,
>y=ForGraph$y,
>x=ForGraph$z,
>surface=FALSE,grid=TRUE,sphere.size=4
>,xlab="Categories",ylab="ScoreRange",
>zlab="VTE Rate (%)",axis.ticks=TRUE)
> dev.off()
>
>

You didn't say what package you found scatter3d in, but you did say it
opens an rgl window.  rgl doesn't use R graphics devices, so jpeg() and
the like don't work.

To save an rgl image, you use the rgl::snapshot3d() function.  It only
has support for saving to PNG format.

If you are writing your manuscript in R Markdown or knitr Rnw, there are
ways to have the file included automatically.  There have been methods
to use with Sweave as well, but those aren't being maintained:  people
should use knitr instead.

Duncan Murdoch

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Save a graph file use jpeg(file=file)

2022-01-05 Thread Ebert,Timothy Aaron
The simple solution for Windows is to use (windows icon) + shift + s. You then 
select a portion of your screen and it gets copied to your clipboard. You can 
then paste that into your document. Of course this will not work if it is 
important that the reader is able to rotate the graphic. 
Tim

-Original Message-
From: R-help  On Behalf Of Sorkin, John
Sent: Wednesday, January 5, 2022 2:46 PM
To: r-help@r-project.org (r-help@r-project.org) 
Subject: [R] Save a graph file use jpeg(file=file)

[External Email]

I am trying to create a 3-D graph (using scatter3d) and save the graph to a 
file so I can insert the graph into a manuscript. I am able to create the 
graph. When I run the code below an RGL window opens that has the graph. The 
file is saved to disk after dev.odd() runs. Unfortunately, when I open the 
saved file, all I see is a white window. Can someone tell me how to have the 
file so I can subsequently read and place the file in a paper? The problem 
occurs regardless of the format in which I try to save the file, e.g. png, tiff.


x <- 1:10
y <- 2:11
z <- y+rnorm(10)
ForGraph<-data.frame(x=x,y=y,z=z)
ForGraph

gpathj <- file.path("C:","LAL","test.jpeg") gpathj jpeg(file = gpathj) par(mai 
= c(0.5, 0.5, 0.5, 0.5)) scatter3d(z=ForGraph$x,
  y=ForGraph$y,
  x=ForGraph$z,
  surface=FALSE,grid=TRUE,sphere.size=4
  ,xlab="Categories",ylab="ScoreRange",
  zlab="VTE Rate (%)",axis.ticks=TRUE)
dev.off()


Thank you,
John


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=9AMmnr8IGTA1cG1beZmaYb3IDwiObdbc6OI3PkjbwbniR_W4i9hcMzYbyzYTE-gS=2IkUWGiufhME4qqOuIRPGShSOMTsStDDwSkLoTt4zdM=
PLEASE do read the posting guide 
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=9AMmnr8IGTA1cG1beZmaYb3IDwiObdbc6OI3PkjbwbniR_W4i9hcMzYbyzYTE-gS=NHEqSQ0hFwKq_5lC0CqVYr53rYXLTpdWVNXZMCEMLLI=
and provide commented, minimal, self-contained, reproducible code.

__
R-help@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.


Re: [R] Save a graph file use jpeg(file=file)

2022-01-05 Thread Sorkin, John
Tim
Thank you for your suggestion. The problem with your suggestion is that the 
copied image is low resolution, 96dpi. Saved files can have higher resolution.
Thank you
John

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to 
faxing)

On Jan 5, 2022, at 2:59 PM, Ebert,Timothy Aaron  wrote:

The simple solution for Windows is to use (windows icon) + shift + s. You then 
select a portion of your screen and it gets copied to your clipboard. You can 
then paste that into your document. Of course this will not work if it is 
important that the reader is able to rotate the graphic.
Tim

-Original Message-
From: R-help  On Behalf Of Sorkin, John
Sent: Wednesday, January 5, 2022 2:46 PM
To: r-help@r-project.org (r-help@r-project.org) 
Subject: [R] Save a graph file use jpeg(file=file)

[External Email]

I am trying to create a 3-D graph (using scatter3d) and save the graph to a 
file so I can insert the graph into a manuscript. I am able to create the 
graph. When I run the code below an RGL window opens that has the graph. The 
file is saved to disk after dev.odd() runs. Unfortunately, when I open the 
saved file, all I see is a white window. Can someone tell me how to have the 
file so I can subsequently read and place the file in a paper? The problem 
occurs regardless of the format in which I try to save the file, e.g. png, tiff.


x <- 1:10
y <- 2:11
z <- y+rnorm(10)
ForGraph<-data.frame(x=x,y=y,z=z)
ForGraph

gpathj <- file.path("C:","LAL","test.jpeg") gpathj jpeg(file = gpathj) par(mai 
= c(0.5, 0.5, 0.5, 0.5)) scatter3d(z=ForGraph$x,
 y=ForGraph$y,
 x=ForGraph$z,
 surface=FALSE,grid=TRUE,sphere.size=4
 ,xlab="Categories",ylab="ScoreRange",
 zlab="VTE Rate (%)",axis.ticks=TRUE)
dev.off()


Thank you,
John


   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.proofpoint.com%2Fv2%2Furl%3Fu%3Dhttps-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp%26d%3DDwICAg%26c%3DsJ6xIWYx-zLMB3EPkvcnVg%26r%3D9PEhQh2kVeAsRzsn7AkP-g%26m%3D9AMmnr8IGTA1cG1beZmaYb3IDwiObdbc6OI3PkjbwbniR_W4i9hcMzYbyzYTE-gS%26s%3D2IkUWGiufhME4qqOuIRPGShSOMTsStDDwSkLoTt4zdM%26e%3Ddata=04%7C01%7Cjsorkin%40som.umaryland.edu%7C9e6f54c1880f46b971f608d9d085e667%7C717009a620de461a88940312a395cac9%7C0%7C0%7C637770095783063118%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=g0489Q9jetIGpbYyjL%2FY2LTKxKud5r4EnFoDlP6uO5c%3Dreserved=0
PLEASE do read the posting guide 
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.proofpoint.com%2Fv2%2Furl%3Fu%3Dhttp-3A__www.R-2Dproject.org_posting-2Dguide.html%26d%3DDwICAg%26c%3DsJ6xIWYx-zLMB3EPkvcnVg%26r%3D9PEhQh2kVeAsRzsn7AkP-g%26m%3D9AMmnr8IGTA1cG1beZmaYb3IDwiObdbc6OI3PkjbwbniR_W4i9hcMzYbyzYTE-gS%26s%3DNHEqSQ0hFwKq_5lC0CqVYr53rYXLTpdWVNXZMCEMLLI%26e%3Ddata=04%7C01%7Cjsorkin%40som.umaryland.edu%7C9e6f54c1880f46b971f608d9d085e667%7C717009a620de461a88940312a395cac9%7C0%7C0%7C637770095783063118%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=8vRn%2FuQJVjFydNfiXOQKIyYBDM3EXXBdBRCccHQnvWY%3Dreserved=0
and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Save a graph file use jpeg(file=file)

2022-01-05 Thread Duncan Murdoch

On 05/01/2022 2:45 p.m., Sorkin, John wrote:

I am trying to create a 3-D graph (using scatter3d) and save the graph to a 
file so I can insert the graph into a manuscript. I am able to create the 
graph. When I run the code below an RGL window opens that has the graph. The 
file is saved to disk after dev.odd() runs. Unfortunately, when I open the 
saved file, all I see is a white window. Can someone tell me how to have the 
file so I can subsequently read and place the file in a paper? The problem 
occurs regardless of the format in which I try to save the file, e.g. png, tiff.


x <- 1:10
y <- 2:11
z <- y+rnorm(10)
ForGraph<-data.frame(x=x,y=y,z=z)
ForGraph

gpathj <- file.path("C:","LAL","test.jpeg")
gpathj
jpeg(file = gpathj)
par(mai = c(0.5, 0.5, 0.5, 0.5))
scatter3d(z=ForGraph$x,
   y=ForGraph$y,
   x=ForGraph$z,
   surface=FALSE,grid=TRUE,sphere.size=4
   ,xlab="Categories",ylab="ScoreRange",
   zlab="VTE Rate (%)",axis.ticks=TRUE)
dev.off()




You didn't say what package you found scatter3d in, but you did say it 
opens an rgl window.  rgl doesn't use R graphics devices, so jpeg() and 
the like don't work.


To save an rgl image, you use the rgl::snapshot3d() function.  It only 
has support for saving to PNG format.


If you are writing your manuscript in R Markdown or knitr Rnw, there are 
ways to have the file included automatically.  There have been methods 
to use with Sweave as well, but those aren't being maintained:  people 
should use knitr instead.


Duncan Murdoch

__
R-help@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.