I have a rather peculiar problem in paneling with cowplot and exporting the result as a PDF file.
Consider the following MWE:
# Load libraries
library(consort)
library(cowplot)
library(ggplotify)
# Create data for flowchart A
participant_id <- 1:10
exclusion <- rep(NA, 10)
exclusion[1:3] <- "Lost to follow-up"
df <- data.frame(participant_id, exclusion)
# Create the flowchart A
flowchart_a <- consort_plot(data = df,
orders = c(participant_id = "Invited participants",
exclusion = "Excluded",
participant_id = "Completed the study"),
side_box = c("exclusion"),
cex = 0.9)
plot(flowchart_a)
# Destroy unneeded vectors
rm(participant_id, exclusion, df)
# Create data for flowchart B
participant_id <- 1:10
exclusion <- rep(NA, 10)
exclusion[1:2] <- "Lost to follow-up"
df <- data.frame(participant_id, exclusion)
# Create the flowchart B
flowchart_b <- consort_plot(data = df,
orders = c(participant_id = "Invited participants",
exclusion = "Excluded",
participant_id = "Completed the study"),
side_box = c("exclusion"),
cex = 0.9)
plot(flowchart_b)
Created on 2023-07-29 with reprex v2.0.2
# Destroy unneeded vectors
rm(participant_id, exclusion, df)
# Turn the consort_plot objects into graphical objects (= grobs) for paneling
grob1 <- as.grob(function() plot(flowchart_a))
grob2 <- as.grob(function() plot(flowchart_b))
# Create panel
grid <- plot_grid(grob1, NULL, grob2,
rel_heights = c(1, 0.3, 1),
labels = c("A", "", "B"),
ncol = 1)
# Save the panel to a PDF file
save_plot("panel.pdf", grid, nrow = 2, ncol = 1.5)
Finally, when creating a panel of these little graphs with cowplot and exporting it as a PDF, the bullets turn into ellipses (see image below). What is curious is that exporting to a PNG works without that problem.