Menu

Saving a graph

Help
ghd
2008-11-20
2013-01-15
  • ghd

    ghd - 2008-11-20

    Hello,

    I used to have no problem saving graphs before (can't remember the exact way but using print to file)
    upgrading to RKWARD 0.5.0b (KDE 4.0.3). but now i have yet to figure how. Say i do:

    > contour(x,y,z)

    this shows in Graphics Device 2... how do i it in RKWARD's ouput window?

    Alternatively,

    > plot(rnorm(10),rnorm(10))
    + dev.copy2eps(file="test.eps")
    X11cairo
           2
    The resulting file home/test seems to have the required properties:
    Type:    EPS image
    Size:    3.5KB
    MIME:   image/x-eps

    but if I open it with Document Viewer it shows Loading... There's also a little Watch in the bottom right of the file icon. This usually happens in the process of saving or downloading a file.

    thanks!

    x86_64-pc/Ubuntu 8.04/Genome 2.22.3/R2.8.0

     
    • fsando

      fsando - 2008-11-21

      Hi
      What I'm going to suggest is more of a hack but I think it points the way to a long term solution.
      In rkward graphs are made through a call to the function

      rk.graph.on()

      This function creates graph images in the ~/.rkward folder.
      It automatically names graph.01.png, graph.02.png etc. (or something very similar)

      When I make graphs now I always write code like this

      rk.graph.on()
      plot(x,y....)
      rk.grahp.off()

      The image is not actually created until rk.graph.off() is run.

      I made a my own version of this command to control the size and name of the image file I didn't go into the automatic the enumeration so it always appends a number to the filename but it could probably be changed with some more code digging.

      a3q_rk.graph.on <- function (width = 480, height = 480,prefix="graph", ...)
      {
          filename <- rk.get.tempfile.name(prefix = prefix, extension = ".png")
          png(filename = file.path(filename), width = width, height = height,
              ...)
          cat(paste("<img src=\&quot;", filename, "\&quot; width=\&quot;", width,
              "\&quot; height=\&quot;", height, "\&quot;><br>", sep = ""), file = rk.get.output.html.file(),
              append = TRUE)
      }

      It is called like this
      a3q_rk.graph.on(width,height,graph_name)
      plot(x,y....)
      rk.grahp.off()

       
    • ghd

      ghd - 2008-11-27

      Thanks!