Questions tagged [patchwork]
patchwork is an R package by Thomas Lin Pedersen providing a simple API for composing multiple plots from the ggplot2 package system.
patchwork
212
questions
0
votes
1
answer
44
views
Collecting Axes using plot_layout() in Patchwork: Aligning and Plotting Sediment Core Images and Downhole Logs
Using a combination of ggplot2, magick, and patchwork, I've gotten pretty close to getting a programmatic sediment core downhole log plot with a scaled photograph aligned along the left y-axis. See ...
2
votes
1
answer
41
views
patchwork - inset_element(): size and position
I have two plots.
The first one (big) is the one which should function as the "background plot".
The second (small) should be the inset.
How can i adjust the size of the inset?
How to ...
1
vote
3
answers
96
views
+350
How to align inset map (with coord_sf) in patchwork?
I'd like to plot an inset map in the top left corner of another map using package patchwork. Yet, when using coord_sf(), the alignment does not work anymore. How to solve this to ensure the inset map ...
2
votes
1
answer
31
views
Draw lines connecting individual data points in grouped bar plot - ggplot
I have a grouped bar plot (two conditions with two groups in each). I am not having trouble creating the group bar plots, but I am interested in putting individual data points on the plot and ...
0
votes
0
answers
34
views
Converting a data.tree object into a dendrogram to use in ggplot2
I have run an R package (scSHC) that, given a dataset and a list of clustering labels, it re-analyzes the data and returns a data.tree object with the statistically significant clusters, and a list of ...
1
vote
1
answer
52
views
Plot too Wide in Patchwork (R)
I've been struggling to understand the patchwork package in R. The barchart on the right of the plot should be much thinner, like the one on top of the scatter plot. Below is my code. Any suggestions?
...
2
votes
1
answer
27
views
Only collect partial of legends with patchwork
I am trying to only "collect" partial of legends with patchwork, below is a minimal example.
library(patchwork)
library(ggplot2)
p1 <- ggplot(mtcars, aes(mpg, disp, color = factor(vs))) +...
2
votes
2
answers
168
views
Specify which legend to keep in wrap_plots
I'm looking to combine multiple graphs generated from different functions into a single display. Specifically, I want to only keep the legend of the first graph in the wrap.
Here is a minimal version ...
2
votes
2
answers
63
views
Add annotation or title outsides border
In this example, I added a border to the three plots:
library(ggplot2)
library(patchwork)
theme_border <- theme_gray() +
theme(plot.background = element_rect(fill = NA, colour = 'black',
...
0
votes
1
answer
37
views
Align y axis labels
I am creating three seperate plots which I then combine using patchwork. The third plot that I make uses facet_grid in order to add a secondary x axis with the years showing. But I think this somehow ...
1
vote
1
answer
112
views
Combining Plotly and ggplot2 charts with Patchwork in one Facet
I want to combine two charts prepared with Plotly and ggplot2 into one PDF. Below, you can see the code for the preparation of the charts:
library(ggplot2)
library(plotly)
library(dplyr)
library(...
0
votes
1
answer
26
views
Misaligned patchwork of facets when using free scaling and mixed-format labels
library(tidyverse)
library(scales)
library(patchwork)
df <- tibble(
date = rep(seq(ymd("2024-01-01"), ymd("2024-12-01"), by = "month"), 2),
var1 = c(seq(1e6, 2....
0
votes
1
answer
66
views
How to align plots with facet_wrap2 and patchwork?
I am having difficulty aligning my grid figure correctly when I have removed the repeating tick labels on the y-axis while combining other facet wraps with different length tick labels in patchwork. I ...
2
votes
0
answers
46
views
How to import operators from the patchwork package into my own package in R?
Similar questions have been asked here, here, and here. However, they don't exactly solve the issue Im having.
Essentially, I am creating a package that has a function that creates a bar plot and then ...
0
votes
1
answer
86
views
How do I combine several ggplot2 plots using patchwork?
When trying to add two ggplot objects (plots) using + from patchwork, I get the error as shown below. What could be the issue?
require(patchwork)
ex.df <- data.table(
x1 = rnorm(1000, 20, 50),
...