You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature request:
It would be really useful if annotations could be placed like legends indicating their relative position (legend.placement = c(1,0)) in the plot area.
Being able to do this before building the plot would be a really neat feature, e.g. for placing regression formulae nicely in a corner.
Something like:
Reacted by Jakub, Artem Klevtsov, Harris McGehee, Thiago V. dos Santos, Chun-Jie Liu, Rafael H M Pereira, Zach Lipp, R Steiner, Marc Elosua Bayés, jameswagstaff and 1 more
the trick also applies to annotation_custom; while answering it the thought occurred to me that one could define complex positions, such as x = 1 - 2i, which would mean "2 data units to the left of the right edge". (actually, I was thinking of absolute vs relative grid units, but it's a similar idea). Claudia B. inspired this with her hyperSpec package, where complex numbers are used to encode similarly dual information.
Making this explicit and separated by axis would be a welcome addition. For example, I'd like to be able to choose the x-value of an annotation explicitly and have the y-value 50% up the plot.
It would be really useful if annotations could be placed like legends indicating their relative position (legend.placement = c(1,0)) in the plot area.
I agree!
annotate("text", -Inf, Inf, ...
That solution will place a annotation into every facet, where legend.placement places a single annotation based on the relative position in the graph, regardless of the other geoms or facets being used.
I would like to see something like annotate_relative or annotate_global to provide this functionality.
annotation_custom provides a way by wrapping an arbitrary grob in a gTree that spans the full panel. The syntax is not super convenient, especially since one has to load grid to use unit and gTree, but there could be a convenience function around this.
To specify specific facets, one would need a geom_custom, which exists as proof-of-principle in egg, but not on CRAN because ggplot2 internal changes in layout.
Activity
hadley commentedon Aug 5, 2015
You can already do it :) (for that special case)
gdkrmr commentedon Aug 5, 2015
Thanks, I wasn't aware of that!
gdkrmr commentedon Aug 5, 2015
@hadley btw. this feature is missing in the documentation
hadley commentedon Aug 5, 2015
It's in the book ;)
baptiste commentedon Aug 8, 2015
the trick also applies to
annotation_custom; while answering it the thought occurred to me that one could define complex positions, such asx = 1 - 2i, which would mean "2 data units to the left of the right edge". (actually, I was thinking of absolute vs relative grid units, but it's a similar idea). Claudia B. inspired this with her hyperSpec package, where complex numbers are used to encode similarly dual information.Just throwing the idea out there, just in case :)
kendonB commentedon Nov 29, 2016
Making this explicit and separated by axis would be a welcome addition. For example, I'd like to be able to choose the x-value of an annotation explicitly and have the y-value 50% up the plot.
baptiste commentedon Nov 29, 2016
@kendonB
qplot(1:10,1:10, geom="blank") + annotation_custom(textGrob("y centered"),xmin=3,xmax=3)kendonB commentedon Nov 29, 2016
Thanks so much @baptiste. Is there any way to also have hjust/vjust in this?
colinbrislawn commentedon May 9, 2018
I agree!
That solution will place a annotation into every facet, where
legend.placementplaces a single annotation based on the relative position in the graph, regardless of the other geoms or facets being used.I would like to see something like
annotate_relativeorannotate_globalto provide this functionality.baptiste commentedon May 9, 2018
annotation_customprovides a way by wrapping an arbitrary grob in a gTree that spans the full panel. The syntax is not super convenient, especially since one has to load grid to useunitandgTree, but there could be a convenience function around this.To specify specific facets, one would need a
geom_custom, which exists as proof-of-principle inegg, but not on CRAN because ggplot2 internal changes in layout.lock commentedon Nov 5, 2018
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/