Rstudio does not print plots

Hi

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

  1. set dpi once or make it a variable
  2. prepare to write the next plot to a tiff file
  3. plot it
  4. 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):

plot(ACET$Temp_UP,ACET$Salt_UP..M. ,ylim=c(0,5.2),col=c("black"), pch= 15,xlim= c(0,125))
points(SRB_S$Temp_UP,SRB_S$Salt_UP..M. ,ylim=c(0,5.2), pch= 1,col=c("black"), xlim= c(0,125))
points(METH$Temp_UP,METH$Salt_UP..M. ,ylim=c(0,5.2), pch= 17,col=c("black"), xlim= c(0,125))

Many thanks in advance!

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.