vertesy / ggExpress

ggExpress is the fastest way to create, annotate and and save plots in R.
https://vertesy.github.io/ggExpress
GNU General Public License v3.0
5 stars 2 forks source link

Error in `qqSave()` argument #7

Closed jn-goe closed 3 years ago

jn-goe commented 3 years ago

Function qqSave() gives the error

 Error in grDevices::png(...) : 
  unused arguments (title = ...)

https://github.com/vertesy/ggExpressDev/blob/87dc94cbe0260c7c525aca7198d263a10b4e98ba/ggExpress.functions.R#L96

vertesy commented 3 years ago

It is expected. You need a ggplot object to save:

myplot = qplot(1) # it is actually ggplot
qqSave(myplot)
vertesy commented 3 years ago

No error on my side, but broken for Julia. Unclear why.

vertesy commented 3 years ago

Still unclear, title field for .PDF will be removed.


qqSave <- function(ggobj, ext =c("png", "pdf")[1], w =4, h = w
                   , page = c(F, "A4p", "A4l", "A5p", "A5l")[1]
                   , title = F, fname = F, ...) {
  if (isFALSE(title)) title <- as.character(substitute(ggobj))
  if (isFALSE(fname)) fname <- kpp(title, ext)
  if (!isFALSE(page)) {
    wA4 <- 8.27
    hA4 <- 11.69
    if ( page == "A4p" ) { w = wA4; h = hA4 }
    if ( page == "A4l" ) { w = hA4; h = wA4 }
    if ( page == "A5p" ) { w = wA4/2; h = hA4/2 }
    if ( page == "A5l" ) { w = hA4/2; h = wA4/2 }
  }
  print(paste0(getwd(),"/", fname))
  # ggsave(plot = ggobj, filename = fname)

  # title <- if (ext == "pdf") ww.ttl_field(title)  else NULL
  cowplot::save_plot(plot = ggobj, filename = fname, base_width = w, base_height = h
                     , title =title
                     , ...)
}