[R] package grid: mirror grob objects along an axis
baptiste auguie
baptiste.auguie at googlemail.com
Sun Jun 3 23:15:27 CEST 2012
Hi,
Another option that you might want to try is the tikzDevice package;
tikz has functions to flip and rotate objects and could it from R with
tikzAnnotate / tikzAnnotateGrob. Of course these objects would not
really be grobs but tikz code, though for text the end result would
probably be the same.
Cheers,
baptiste
On 4 June 2012 08:22, Thomas Zumbrunn <t.zumbrunn at unibas.ch> wrote:
> My question was answered off list by Paul Murrell, author of 'grid'. Here's am
> excerpt of our email exchange for the records of R-help.
>
> ======== Paul Murrell ========
>
> In some special cases, you would be able to "flip" shapes. If the
> coordinates of the shapes are given in "native" coordinates, then you
> could reverse the scales on the viewport that you are drawing in.
>
> However, there is no general "flip" operation in 'grid'. Especially not
> with respect to text. Text is always left-to-right and sized using
> absolute units (points [modulo cex multipliers]).
>
> If you really desperately needed to do something like this, a last
> resort might be to draw the required "scene" in hi-res raster format.
> You could then easily flip the raster and draw that.
>
> ======== Thomas Zumbrunn ========
>
> I was actually asking the question primarily because I wanted to flip text
> grobs...
>
>> If you really desperately needed to do something like this, a last
>> resort might be to draw the required "scene" in hi-res raster format.
>> You could then easily flip the raster and draw that.
>
> That's exactly what I did as a workaround, but I was hoping that there is a
> more elegant solution - especially since reading in and drawing hi-res raster
> format images slows down the execution time of my code quite considerably.
>
> What about converting text into paths? Could one do this in R? Then one could
> use your suggested solution of reversing the scales of the viewport.
>
> ======== Paul Murrell ========
>
> Interesting idea. You could do that using the 'grImport'. Something
> like ...
>
> library(grid)
> postscript("test.ps")
> grid.text("test")
> dev.off()
>
> library(grImport)
> PostScriptTrace("test.ps", "test.xml")
> test <- readPicture("test.xml")
> # To check the scales on the picture
> # test at summary
> grid.picture(test,
> yscale=c(4400, 4000),
> xscale=c(2936.84, 3019.76))
>
>
>
>
> On Tuesday 22 May 2012, Thomas Zumbrunn wrote:
>> Hi everyone
>>
>> I'd like to flip grobs (grid graphical objects) along an axis, e.g. flip
>> grobs horizontally or vertically. I couldn't find any hints, neither in
>> the documentation nor by searching the web. Does anybody know how to
>> achieve this?
>>
>> Cheers
>> /thomas
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list