cowplot

The draw_image() function from cowplot results in blurred pdfs

三世轮回 提交于 2021-01-27 14:34:11
问题 Reading a vectorized pdf sometimes result in a badly blurred image with the draw_image() function from cowplot: library(ggplot2) library(cowplot) library(magick) # make pdf input as example p <- ggplot(iris, aes(Sepal.Length, Sepal.Width, shape = Species)) + geom_point() + scale_shape_manual(values = 21:23) + theme_classic() ggsave("input.pdf", p, width = 6, height = 4.2) # now draw with draw_image() and then write as png fig <- ggdraw() + draw_image("input.pdf") ggsave("output.png", fig,

Centered X-axis label for muliplot using cowplot package

爱⌒轻易说出口 提交于 2020-07-04 13:26:06
问题 I have a multiplot figure consisting of 4 plots in a 2x2 configuration. I arranged the plots using the "cowplot" package and the plot_grid function using the code below plot_grid(p1, p2, p3, p4, align='vh', vjust=1, scale = 1) where p1-p4 are my 4 plots. The resulting figure has an x-axis label associated with each column in the multiplot: Does anyone know how I can code a single x-axis label centered at the bottom of the multiplot, either with cowplot or another way? 回答1: Another option is

Joining a dendrogram and a heatmap

ⅰ亾dé卋堺 提交于 2020-06-24 07:06:13
问题 I have a heatmap (gene expression from a set of samples): set.seed(10) mat <- matrix(rnorm(24*10,mean=1,sd=2),nrow=24,ncol=10,dimnames=list(paste("g",1:24,sep=""),paste("sample",1:10,sep=""))) dend <- as.dendrogram(hclust(dist(mat))) row.ord <- order.dendrogram(dend) mat <- matrix(mat[row.ord,],nrow=24,ncol=10,dimnames=list(rownames(mat)[row.ord],colnames(mat))) mat.df <- reshape2::melt(mat,value.name="expr",varnames=c("gene","sample")) require(ggplot2) map1.plot <- ggplot(mat.df,aes(x=sample

How to add one common y and x label for an arrange of plots and also a label for several columns of this arrange in R?

拜拜、爱过 提交于 2020-06-17 09:08:34
问题 I have an arrange of 16 plots (4x4). The last column of this arrange is the legend, that is common for each row. I add below a fake code to create something similar to what I have: library(ggplot2) library(cowplot) library(ggpubr) theme_set(theme_cowplot()) df1 <- data.frame(x = 1:12, y = (1:12)^2) df1$grp = c('A', 'B', 'C') df2 <- data.frame(x = 1:12, y = (1:12)^2) df2$grp = c('D', 'E') df3 <- data.frame(x = 1:12, y = (1:12)^2) df3$grp = c('F', 'G', 'H','I') df4 <- data.frame(x = 1:12, y =

How to align legends included in the plots of the last column of an arrange of plots using `plot_grid` from `cowplot` package?

馋奶兔 提交于 2020-06-01 05:10:51
问题 I have arranged 16 plots (4x4) using plot_grid from cowplot package. I would like to align last column of my arrange to get all the legends to be symmetrical vertically. I have read this but I don't get what I want. I don't know why it doesn't work. arrange <- plot_grid(P.ADelay.5m,P.ADelay.15m,P.ADelay.25m,P.ADelay.35m + theme(legend.justification = c(0,1)), P.SW.5m,P.SW.15m,P.SW.25m,P.SW.35m + theme(legend.justification = c(0,1)), P.Method.5m,P.Method.15m,P.Method.25m,P.Method.35m + theme

How do I leave the graph centralized by ggplot2

此生再无相见时 提交于 2020-05-14 14:21:20
问题 I have following commands by cowplot require(cowplot); tiff('./solution/AGM2.tiff', height = 18,width = 25, units = 'in',res = 60) plot_grid(a28 + theme(axis.title.y = element_text(size =40), axis.title.x=element_text(size =40), axis.text.x=element_text(size =35), axis.text.y=element_text(size =40), title=element_text(size = 30), legend.text=element_text(size = 30)), a33 + theme(axis.title.y = element_text(size =40), axis.title.x=element_text(size =40), axis.text.x=element_text(size =35),

Setting width and height of a single panel in multi-panel plot in cowplot::plot_grid

心不动则不痛 提交于 2020-04-16 04:25:25
问题 I am making a multi-panel plot using ggplot2 and cowplot packages, but I need to change the height of a single plot. It is easiest shown with an example library(ggplot2) library(cowplot) p1 <- ggplot(iris, aes(Sepal.Width, Sepal.Length, colour = Species)) + geom_point() + theme(axis.text.x = element_blank(), axis.title.x = element_blank(), legend.position = "none") p2 <- ggplot(iris, aes(Sepal.Width, Sepal.Length, colour = Species)) + geom_point() + theme(axis.text.x = element_blank(), axis

Add a common legend

旧城冷巷雨未停 提交于 2020-01-23 12:17:53
问题 I was trying to do a multiplot with ggplot2 . This was my initial code nucmer_s1 <- ggarrange(eight_uniform, ten_uniform, twelve_uniform, fourteen_uniform, sixteen_uniform, ncol=3, nrow=2, common.legend = TRUE, legend="bottom") getting this error Error in plot$scales : $ operator is invalid for atomic vectors then. annotate_figure(nucmer_s1, top = text_grob("Genomas validados con distribución de datos equilibrada", color = "black", face = "bold", size = 12)) however I obtain the graphic But I

ggplot2 - How to add labels to multiple plots figure?

放肆的年华 提交于 2020-01-06 07:21:09
问题 I need to add one x label and one y label to the following multiple plots figure using cowplot : library(ggplot2 set.seed(99) x_1 = data.frame(z = rnorm(100)) x_2 = data.frame(z = rnorm(100)) x_3 = data.frame(z = rnorm(100)) lst = list(x_1, x_2, x_3) lst_p = list() for (i in 1:length(lst)) { lst_p[[i]] = ggplot(data=lst[[i]], aes(lst[[i]]$z)) + geom_histogram() + xlab("X LAB") + ylab("Y LAB") } p_no_labels = lapply(lst_p, function(x) x + xlab("") + ylab("")) title = cowplot::ggdraw() +

Longer plot labels move to the right when arranging plots with plot_grid from cowplot

淺唱寂寞╮ 提交于 2020-01-06 06:18:09
问题 I was asked this question on Twitter and thought it might be good to have it here. When making labeled, side-by-side plots with plot_grid() , things work as expected for single-letter labels: library(cowplot) p1 <- ggplot(iris, aes(x = Sepal.Length, fill = Species)) + geom_density(alpha = 0.7) + ggtitle("") + theme_minimal() p2 <- ggplot(iris, aes(x = Sepal.Length, fill = Species)) + geom_density(alpha = 0.7) + ggtitle("") + scale_fill_grey() + theme_minimal() plot_grid(p1, p2, labels = c("A"