-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extracting positions (x and y coordinates) of a drawn grid grob #18
Comments
Are you looking for |
I tried using them but they aren't returning anything useful: (just returns the name of 'rotationgrobaxis', where rotation is the angle equivalent of the direction-based theta value provided, and axis is either x or y depending upon use of grobX or grobY) > df <- data.frame(i=1:10, label="more
+ than
+ one
+ line
+ really
+ a
+ lot")
> library(ggplot2)
> gg <- ggplot(df, aes(i, i, color=label)) + geom_line()
> library(directlabels)
> direct.label(gg, "right.polygons")
> library(grid)
> grid.force()
> grid.ls(fullNames = TRUE)
forcedgrob[layout]
forcedgrob[background.1-9-12-1]
forcedgrob[panel.7-5-7-5]
gTree[grill.gTree.14]
rect[panel.background..rect.5]
polyline[panel.grid.minor.y..polyline.7]
polyline[panel.grid.minor.x..polyline.9]
polyline[panel.grid.major.y..polyline.11]
polyline[panel.grid.major.x..polyline.13]
zeroGrob[NULL]
polyline[GRID.polyline.1]
dlgrob[GRID.dlgrob.1.right.polygons]
zeroGrob[NULL]
zeroGrob[panel.border..zeroGrob.2]
forcedgrob[spacer.8-6-8-6]
forcedgrob[spacer.8-4-8-4]
forcedgrob[spacer.6-6-6-6]
forcedgrob[spacer.6-4-6-4]
forcedgrob[axis-t.6-5-6-5]
forcedgrob[axis-l.7-4-7-4]
zeroGrob[NULL]
forcedgrob[axis]
forcedgrob[axis.1-1-1-1]
text[GRID.text.22]
forcedgrob[axis.1-2-1-2]
forcedgrob[axis-r.7-6-7-6]
forcedgrob[axis-b.8-5-8-5]
zeroGrob[NULL]
forcedgrob[axis]
forcedgrob[axis.1-1-1-1]
forcedgrob[axis.2-1-2-1]
text[GRID.text.17]
forcedgrob[xlab-t.5-5-5-5]
forcedgrob[xlab-b.9-5-9-5]
text[GRID.text.26]
forcedgrob[ylab-l.7-3-7-3]
text[GRID.text.30]
forcedgrob[ylab-r.7-7-7-7]
forcedgrob[subtitle.4-5-4-5]
forcedgrob[title.3-5-3-5]
forcedgrob[caption.10-5-10-5]
forcedgrob[tag.2-2-2-2]
> y1 <- grid::grobY("GRID.dlgrob.1.right.polygons","north")
> y1
[1] 90groby
> class(y1)
[1] "unit" "unit_v2"
> y2 <- grid::grobY("panel.grid.major.x..polyline.13","north")
> y2
[1] 90groby Also, as you can see from the above they're returning the exact same thing for two different grobs. Am I doing something wrong? |
It depends on your definition of "useful" :)
... or they can be converted to other coordinate systems, e.g., ...
... with the warning that the value of the |
Ah gotcha. I was too quick to assume that they were not useful, but it seems like I can make some use out of them now :) |
Hi @pmur002
I was wondering whether we could acquire the (x, y) positions of a grid grob after it has been drawn (i.e. the x and y coordinates in pairs resembling the points which altogether construct that particular grob) - if that's possible, what would be the approach?
What I'm trying to achieve is to obtain
Link for reference: tdhock/directlabels#41 (comment)
The text was updated successfully, but these errors were encountered: