cowplot

Vertically align of plots of different heights using cowplot::plot_grid() when using coord_equal()

天大地大妈咪最大 提交于 2020-01-04 17:34:08
问题 I am trying to combine two ggplot objects using cowplot::plot_grid() and vertically align them. This is normally quite simple using align = "v" . dat1 <- data.frame(x = rep(1:10, 2), y = 1:20) dat2 <- data.frame(x = 1:10, y = 1:10) plot1 <- ggplot(dat1, aes(x = x, y = y)) + geom_point() plot2 <- ggplot(dat2, aes(x = x, y = y)) + geom_point() cowplot::plot_grid(plot1, plot2, ncol = 1, align = "v") However, this approach fails when the ggplots use coord_equal() because plot_grid() cannot modify

Vertically align of plots of different heights using cowplot::plot_grid() when using coord_equal()

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-04 17:32:21
问题 I am trying to combine two ggplot objects using cowplot::plot_grid() and vertically align them. This is normally quite simple using align = "v" . dat1 <- data.frame(x = rep(1:10, 2), y = 1:20) dat2 <- data.frame(x = 1:10, y = 1:10) plot1 <- ggplot(dat1, aes(x = x, y = y)) + geom_point() plot2 <- ggplot(dat2, aes(x = x, y = y)) + geom_point() cowplot::plot_grid(plot1, plot2, ncol = 1, align = "v") However, this approach fails when the ggplots use coord_equal() because plot_grid() cannot modify

custom axis width with theme after loading cowplot

最后都变了- 提交于 2019-12-24 19:31:55
问题 I am trying to make the X and Y axis lines thicker using theme(axis.line=element_line(size=2)) but cowplot is overriding it. Is there a way to specify XY axis lines size while using cowplot? I tried adding theme(axis.line=element_line(size=2)) to my plot. Cowplot typically respects specifications I pass to theme , but not this one. library(ggplot2) ggplot(mpg, aes(x=trans, y=cty)) + geom_boxplot() + theme( axis.line = element_line(size = 2)) # correct plot ######## library(ggplot2) library

plot_clone error in cowplot

跟風遠走 提交于 2019-12-24 00:37:39
问题 I am trying to use plot_grid in package cowplot to make a 2x2 plot. I keep getting the error message: Error in plot_clone(plot) : attempt to apply non-function And I can't figure out how to correct this. At first I wasn't sure if cowplot could only handle 1x2 or 2x1 layouts, similar to what you see in this vignette. So, following the example near the end, I tried to save two pairs of two to then stack using plot_grid . But whenever I run that function, I get the same error message. My four

ggplot2 - Correctly arrange odd number of plots into one figure

人盡茶涼 提交于 2019-12-23 20:37:35
问题 I have an odd number of plots to arrange into one figure and I desire to show the last plot centered in the last row of the figure. Here some sample data: 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)

Add empty plots to facet, and combine with another facet

筅森魡賤 提交于 2019-12-23 17:45:11
问题 Using this SO solution I created a facet with two "empty" plots, with the aim of combining with another group of facet_wrap plots, as shown below. The purpose is to have two y-axis labels for different unit measurements. How can I make the grid layout look like the top image, which produces the arrangement I want, but not the axis labels? This was accomplished with plot_grid with individual plots. My current output does not scale correctly and overlaps the other plots, as seen in the second

Insert Image/PNG ggplot2 - Cowplot

末鹿安然 提交于 2019-12-23 03:45:12
问题 I'm trying to use cowplot package's draw_image() function. I've managed to get an image in a graph as an example. I can't work out how the xy locations work, I had to keep inputting random numbers until I got to see the image. require(ggplot2) #required packages require(cowplot) require(magick) p1 <- qplot(Sepal.Length, Sepal.Width, data = iris) ggdraw(p1) + draw_image( "https://upload.wikimedia.org/wikipedia/en/7/77/EricCartman.png", y = 0.2, scale = 0.5 ) Can anyone advise on what scale

Disable cowplot default for ggplots

旧时模样 提交于 2019-12-21 07:34:44
问题 The ggplot2 add-on package, cowplot , has a nice function for plotting multiple plots called plot_grid() . Here's plot_grid() in action: library(ggplot2); library(cowplot) plot_a <- ggplot(mtcars, aes(mpg, wt)) + geom_point() plot_b <- ggplot(mtcars, aes(mpg, disp)) + geom_point() plot_grid(plot_a, plot_b, labels = c("A", "B")) But note how loading cowplot changes the default style of plots. How can I load the cowplot package so that I can use the plot_grid() function but also disable the

One shared legend for a cowplot grid in R

被刻印的时光 ゝ 提交于 2019-12-20 10:24:16
问题 I just built a grid with package cowplot (to label the plots from A-D). The plots are made with package ggplot2 : pfour<-ggplot(four, aes(x=Concentration, y=Percentage, fill=Phenotype)) + geom_bar(stat='identity',color='black') + scale_fill_grey(start = .4, end = .9) + theme_bw()+ylab("Distribution") + xlab("Contentration [mg/ml]") + ggtitle("96 hpf") + theme(legend.title = element_text(colour="black", size=10, face="bold")) + theme(legend.background = element_rect(fill="white", size=0.5,

ggplot2: Creating themed title, subtitle with cowplot

吃可爱长大的小学妹 提交于 2019-12-19 08:12:53
问题 I have a list of data frames that I use to make a list of ggplot s, and then assemble into a grid of plots with cowplot . I need to then attach a shared title, subtitle, and caption. I want to do this in a way that these labels will have the same theme elements (size, fontface, etc) as if they were created by labs instead of cowplot::draw_label . In my real situation, I have several choropleths that each have their own units and scales, which is why I can't just facet, but instead need to