Skip to content

[R-pkg-devel] plot graph (png, svg, eps, pdf, vdx, ok tikz) to device

3 messages · Stefan McKinnon Høj-Edwards, Rainer M Krug

#
Hi

I asked the question at stack exchange yesterday ( https://stackoverflow.com/q/50325139/632423 ) and did not get a response so far, so I repost it here:

####

I have the following situation: I use an external command (plantuml - http://plantuml.com/ ) to create a graph. This is done via R by using a (my) package ( https://github.com/rkrug/plantuml ). The resulting graph can be a file (png, svg, eps, pdf, vdx or LaTeX/Tikz with or without preamble) or I can send the image to stdout, using the same formats.

Now I want to plot this graph as R-like as possible, i.e. in a graphic device. At the moment I am using a temporary file, which I display using readPNG() and grid::grid.raster() which works, but I am not that happy with this approach as

	? I have to use a temporary file which I would like to avoid, and
	? it is a raster format and I would prefer a vector format.

My question is therefore:

	? Is there a way to display any of the vector formats in a graphics device in R?
	? Can I pipe stdout (the result from the call to plantuml) directly into the device (or through any function) without having to create an intermediate file?

####

Thanks for any [pointers,

Rainer


--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

University of Z?rich

Cell:       +41 (0)78 630 66 57
email:      Rainer at krugs.de
Skype:      RMkrug

PGP: 0x0F52F982




-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: Message signed with OpenPGP
URL: <https://stat.ethz.ch/pipermail/r-package-devel/attachments/20180515/26f80b1f/attachment.sig>
#
Hi Rainer,

You are currently using a java library to create the plot. Your package is
basically a wrapper around the java file.
The only way to make it more "R-like" would be to re-implement the
rendering in R (or Rcpp or using the grid package).

To get a vector based image, your code suggests you can use the SVG format.
But again, that does not have anything to do with R.

Kindly,
Stefan McKinnon H?j-Edwards

Stefan McKinnon H?j-Edwards
ph.d. Genetics
+44 (0)776 231 2464
+45 2888 6598
Skype: stefan_edwards

2018-05-15 13:22 GMT+02:00 Rainer Krug <Rainer at krugs.de>:

  
  
#
Hi Stefan,
Correct - that why I am limited to using the specified output formats.
Yes - I want to render the generated graphs in a graphics device in R, as if I would use a plot(1,1) command.
As vector I have sag, eps, and tikz formats - and the R part is: can I render these in an R device. I am not interested in R-like coded in the package, I am simply looking for a way to display this in an R device.

Cheers,

Rainer
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

University of Z?rich

Cell:       +41 (0)78 630 66 57
email:      Rainer at krugs.de
Skype:      RMkrug

PGP: 0x0F52F982




-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: Message signed with OpenPGP
URL: <https://stat.ethz.ch/pipermail/r-package-devel/attachments/20180515/8ecaff0d/attachment.sig>