I am trying to print my plots in Rstudio in high resolution for a journal publication.
I used to previously use TinnR to send commands to R and while the printing of high resolution plots was not a problem I could not run several lines at once, making it very laborious.
with Rstudio it seems the reverse.
Here the code I use to print
dpi=1000 #pixels per square inch
tiff("CORR.fig.2.tiff", width=10.2dpi, height=10dpi, res=dpi)
-then I create my plot -
dev.off()
I have tried with several functions, but it still does not print. Any ideas?
Thanks,
Eike
tiff works by writing the current plot file to a specified filename with the additional arguments given in your example, so the workflow is something along the lines of
set dpi once or make it a variable
prepare to write the next plot to a tiff file
plot it
dev.off
as you are now doing.
The next step is to make a function for these steps and apply it successively to a list of arguments. We'll use the built-in mtcars dataset, with the same resolution for all.
``` r
dpi = 100 #pixels per square inch (instead 1000, for convenience)
plotnames <- c("plot1.tiff","plot2.tiff","plot3.tiff","plot4.tiff","plot5.tiff")
make_tiff <- function(x) dev.print(tiff,file = plotnames[x-2], width=10.2*dpi, height=10*dpi, res=dpi)
make_plot <- function(x) plot(mtcars$mpg,mtcars[,x])
for(i in 3:7){
make_plot(i)
make_tiff(i)
dev.off()
}
thanks for your answer.
I am afraid I do not understand the second part. could you guide me further what to do in my case ?
This is my plotting code (reduced, to make it more transparrent):