This question is an expansion of an earlier discussion, where a good solution is described, but a more brutal combining method might be necessary in some scenarios.

Consider the following MWEs that produce the two bitmaps.

First, graph 1:

# Load packages
library(ggforestplot)
library(tidyverse)
library(ggplot2)
# Use the example data of the ggforesplot() package (only a few rows of it)
df <- ggforestplot::df_linear_associations %>%
  filter(trait == "BMI") %>% slice(26:27)
# Create plot
ggforestplot::forestplot(
  df = df,
  name = name,
  estimate = beta,
  se = se,
  pvalue = pvalue,
  psignif = 0.05
)
# Export as png
ggsave("graph1.png", width = 8, bg = 'white', dpi = 150)

Graph 2:

# Load packages
library(ggstats)
# Load example data
data(tips, package = "reshape")
# Run linear model
linear_model <- lm(tip ~ size + total_bill, data = tips)
# Plot model
ggcoef_model(linear_model)
# Export as png
ggsave("graph2.png", width = 8, bg = 'white', dpi = 150)

Let's say I want to cut a slice (here: a legend) with the height of 79 pixels (ca 10.8%) from the bottom of the 2nd graph (second bitmap file) and append that to the 1st graph (1st bitmap file).

Is there a way to do this straight in R, or alternatively, by incorporating Python code into an R script?

The result I desire is shown below:

enter image description here

0

There are 0 answers