[R] package grid: mirror grob objects along an axis

baptiste auguie baptiste.auguie at googlemail.com
Tue May 22 21:34:21 CEST 2012


Oops, sent too early; this obviously just a rotation, not a mirror
image. It illustrates the problem though ;)

b.

On 23 May 2012 07:32, baptiste auguie <baptiste.auguie at googlemail.com> wrote:
> You can rotate the viewport to flip around the horizontal axis,
>
> library(grid)
> grid.text("Chiral")
> grid.text("Chiral", vp=viewport(angle=180, y=unit(0.5,"npc")-unit(1,"line")))
>
> HTH,
>
> b.
>
> On 23 May 2012 05:34, Thomas Zumbrunn <t.zumbrunn at unibas.ch> wrote:
>> Maybe my question was not concise enough. I was referring to objects created
>> with the "package "grid" (also called "grobs"), not to the function "grid"
>> from package "graphics". For instance, let's say I have a polygon createad
>> with grid::polygonGrob and want to mirror it along a specified axis. Of course
>> one could transform the polygon's coordinates, but I was hoping that there is
>> some more generic way of doing this (and that this could e.g. also be done
>> with text grobs).
>>
>> Cheers
>> /thomas
>>
>>
>>
>> On Tuesday 22 May 2012, Rui Barradas wrote:
>>> Hello,
>>>
>>> Just flip 'xlim' or 'ylim'. Or both.
>>> Using the iris example in help("grid"), make the following changes:
>>>
>>>
>>> op <- par(mfcol = c(2,2))  # Two columns, first is the original, second
>>> flipped.
>>>
>>> with(iris,
>>>
>>>       [... etc ...]
>>>      # row 1, col 2: flip x axis
>>>      plot(Sepal.Length, Sepal.Width, col = as.integer(Species),
>>>           xlim = c(8, 4), ylim = c(2, 4.5), panel.first = grid(),
>>>           main = "with(iris,  plot(...., panel.first = grid(), ..) )")
>>>      # row 2, col 2: flip y axis
>>>      plot(Sepal.Length, Sepal.Width, col = as.integer(Species),
>>>           xlim = c(4, 8), ylim = c(4.5, 2),
>>>           panel.first = grid(3, lty=1,lwd=2),
>>>           main = "... panel.first = grid(3, lty=1,lwd=2), ..")
>>>
>>>      [... etc ...]
>>> )
>>> par(op)
>>>
>>>
>>> Hope this helps,
>>>
>>> Rui Barradas
>>>
>>> Thomas Zumbrunn-3 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@ 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.
>>>
>>> --
>>> View this message in context:
>>> http://r.789695.n4.nabble.com/package-grid-mirror-grob-objects-along-an-ax
>>> is-tp4630866p4630870.html Sent from the R help mailing list archive at
>>> Nabble.com.
>>>
>>> ______________________________________________
>>> 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.
>>
>>
>> --
>> Thomas Zumbrunn, PhD
>> Clinical Trial Unit (CTU)
>> Universitätsspital Basel
>> Schanzenstr. 55, CH-4031 Basel
>> Tel +41 (0)61 556 52 92
>> Fax +41 (0)61 265 94 10
>> http://www.clinicaltrialunit.ch/
>>
>> ______________________________________________
>> 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