Skip to content

Instantly share code, notes, and snippets.

@thanhleviet
Created March 13, 2023 14:34
Show Gist options
  • Save thanhleviet/e374c6c225b9ce1b16b12b12c3dd3610 to your computer and use it in GitHub Desktop.
Save thanhleviet/e374c6c225b9ce1b16b12b12c3dd3610 to your computer and use it in GitHub Desktop.
test patchwork
library(patchwork)
library(ggplot2)
library(tidyverse)
data(mtcars)
data(iris)
mtcars.tf <- mtcars %>%
rownames_to_column("name") %>%
pivot_longer(names_to = "metrics", values_to = "values", mpg:carb)
t1 <- ggplot(data = mtcars.tf) +
geom_tile(aes(y = name, x = metrics, fill = values), color= "white") +
coord_equal()
iris.tf <- iris %>%
pivot_longer(names_to = "Comp", values_to = "values", Sepal.Length:Petal.Width)
t2 <- ggplot(data = iris.tf) +
geom_tile(aes(x = Comp, y = Species, fill = values)) +
scale_fill_continuous(type = "viridis") +
theme(plot.margin = margin(r=0,
l=0,
t=0,
b=0)) +
coord_equal() +
scale_x_discrete(expand=c(0,0)) +
scale_y_discrete(expand=c(0,0))
t1 + t2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment