-
Notifications
You must be signed in to change notification settings - Fork 156
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
Annotate patchwork with line segments to create semantic plot relationships #216
Comments
I agree that that would be very useful, but also non-trivial if at all possible. The reasons for this are pretty technical, but basically the different plots does not occupy a shared coordinate system and figuring out their relative locations are not straight-forward. Don't hold your breath for it 🙂 |
I definitely do not have any of the technical knowledge to pretend to understand how Obviously vector graphics are preferred for various reasons. I'm just thinking out loud. |
Sure, you can just treat it as one big canvas - that is already possible. But there is no way to reference any existing information in the plot so you'd have to position the lines through trial and error. I'd advice just doing it in illustrator/inkscape instead |
Congrats on the CRAN release, Thomas. To follow-up on your above comment, could you point me in the right direction for doing what you described above? I don't actually mind a bit of trial-and-error as long as the end result is reproducible. How does one "flatten" the patchwork into a single big canvas? I have tried using library(magrittr)
library(ggplot2)
library(patchwork)
p1 <-
mtcars %>%
ggplot(aes(mpg, hp)) +
geom_point()
(p1 / p1) + annotate("text", 1, 1, label = "foo") (p1 / p1) & annotate("text", 1, 1, label = "foo") |
@mattwarkentin There is a simple example at the end of this documentation that will yield annotations between ggplots grobs in different viewports in a grid using the package gggrid. gginards geom_debug(), ggpmisc A great inspiration for visualizing relationships between data has been implemented by Susie Lu in d3-annotations d3js and react-annotations of the semiotic framework. |
Hi @thomasp85,
I am wondering if it is currently possible to add line segments (such as those created with
geom_segment()
, for example) or any otherggplot
annotations, on top of a patchwork to be able to create arbitrary relationships between plots. This could be useful for both standard patchworks or inset patchworks to create more obvious relationships between plots. Basically I'm trying to avoid doing any figure post-processing outside ofR
.It is my understanding that the patchwork itself is a
ggplot
object, so I am wondering if this is possible, and if it isn't currently possible, if this feature is feasible. Maybe treating the full patchwork as having x and y dimensions of [0, 1] - so lines could somehow be drawn from and to arbitrary points on the patchwork.patchwork
support forggplot2::annotate()
acting on the full patchwork would allow for some very flexible customization.Here is an illustrative example for what I'm hoping to achieve (I'm hoping to be able to add the dashed lines to arbitrarily connect the subplots in a patchwork):
The text was updated successfully, but these errors were encountered: