Created
March 13, 2023 14:34
-
-
Save thanhleviet/e374c6c225b9ce1b16b12b12c3dd3610 to your computer and use it in GitHub Desktop.
test patchwork
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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