facet-grid

Tukey test results on geom_boxplot with facet_grid

ε祈祈猫儿з 提交于 2019-12-11 07:05:17
问题 I'd love to place letters representing the results of a Tukey's HSD on boxplots I make in ggplot. I am aware of other posts (Tukeys post-hoc on ggplot boxplot, Tukey's results on boxplot in R) but in my case, I work with facet_grid and I am not sure how to proceed. As I am creating a lot of boxplots, I would love to have something automated. Any tips to help me get me started would be greatly appreciated. Thanks a lot library(multcompView) library(ggplot2) #sample dataframe df <- data.frame

Removing y categorical variables facet_grid

好久不见. 提交于 2019-12-11 05:05:08
问题 I am doing a bar plot using ggplot presenting relative abundances of organisms in a community at three sampling sites (column=factor). However, I would like that the facet grid separate the data according to their factor (all factor 1 in top grid, all factor 2 in middle grid, and all factor 3 in lower grid). Currently, all the samples (y value) appear in each grid. > head(facet,50) ID Taxa Samples value factor 1 1 Ciliates DNAHOR5m 0.040637972 1 2 2 Dinoflagellates DNAHOR5m 0.265239240 1 3 3

R: facet_wrap does not render correctly with ggplotly in Shiny app

江枫思渺然 提交于 2019-12-08 05:20:36
问题 When I do a facet_grid in ggplotly() for a Shiny App, with a large number of faceting groups, the plot is messed up. However it works correctly outside Shiny. How can I fix this? I suspect it is linked to the Y scale but I couldn't find the solution. Here's a reproducible example based on diamonds example from plotly. Comparison of Shiny vs non Shiny outputs : Comparison of facet_grid outside and within Shiny Code Outside Shiny: library(ggplot2) data(diamonds, package = "ggplot2") # new

Seaborn FacetGrid - Place single colorbar after last subplot

白昼怎懂夜的黑 提交于 2019-12-07 15:17:05
问题 I'm trying to add a colorbar to a grid of 3 seaborn plots. I am able to add the colorbar to the 3 individual plots, or squeeze a colour bar next to the 3rd plot. I would like to have a single colorbar after the 3rd plot, without changing the size of the last plot. I got lots of good ideas from this answer, but couldn't solve my exact problem: SO Question/Answer Here is my current code: import seaborn as sns def masked_vs_unmasked_facets(output_dir, merged_df, target_col, thresholds): #

ggplot2: Deleting facets of unused factor level combinations from a plot (facet_grid)

感情迁移 提交于 2019-12-07 01:55:23
问题 I would like to selectively delete unnecessary facets from a facetted ggplot2 figure. I had a look at this question but could not figure out how to do it (maybe the advise there is outdated now): adding empty graphs to facet_wrap in ggplot2 Here is a minimal example. I would like to remove the empty facet at the right bottom (b, 2). library('ggplot2') d <- data.frame('factor_1' = factor(c('a', 'a', 'b')), 'factor_2' = factor(c('1', '2', '1')), x = 1:3, y = 1:3) ggplot(data = d, mapping = aes

ggplot2 outside panel border when using facet

拈花ヽ惹草 提交于 2019-12-07 00:28:38
问题 I would like to have a border around the outside of my faceted plot but not have the lines that separate the panels inside the plot. The issue is that panel.border draws a border around each panel in the facet with no option to just have a border around the entire plot. Alternatively can you set the inside dividing lines to 'white' but keep the outside border 'black'. Here is my code: mtcars mtcars$manufacturer=rownames(mtcars) ggplot(mtcars, aes(x=manufacturer, y=mpg,fill=factor(gear,levels

R: facet_wrap does not render correctly with ggplotly in Shiny app

戏子无情 提交于 2019-12-06 14:39:58
When I do a facet_grid in ggplotly() for a Shiny App, with a large number of faceting groups, the plot is messed up. However it works correctly outside Shiny. How can I fix this? I suspect it is linked to the Y scale but I couldn't find the solution. Here's a reproducible example based on diamonds example from plotly . Comparison of Shiny vs non Shiny outputs : Comparison of facet_grid outside and within Shiny Code Outside Shiny: library(ggplot2) data(diamonds, package = "ggplot2") # new faceting group diamonds$rdmGroup <- as.factor(sample(LETTERS, dim(diamonds)[1], replace=TRUE)) # subset of

Multiple rows in facet_grid

↘锁芯ラ 提交于 2019-12-06 06:00:47
问题 I have a dataset that looks roughly like this: names = tibble(NAME_2=c("Location1","Location2","Location3","Location4")) dates = tibble(date = seq(as.Date("2015-01-01"), as.Date("2016-12-31"), by="days")) types = tibble(type = c("comment","post")) df <- merge(names,dates) df <- merge(df, types) zero <- seq(from=0, to=200, by=1) df$n <- sample(zero, size=nrow(df), replace=TRUE) Which produces a facet plot like this: ggplot(data = df, aes(x = date, y = n)) + geom_line() + facet_grid(type ~ NAME

ggplot2: Deleting facets of unused factor level combinations from a plot (facet_grid)

江枫思渺然 提交于 2019-12-05 08:35:53
I would like to selectively delete unnecessary facets from a facetted ggplot2 figure. I had a look at this question but could not figure out how to do it (maybe the advise there is outdated now): adding empty graphs to facet_wrap in ggplot2 Here is a minimal example. I would like to remove the empty facet at the right bottom (b, 2). library('ggplot2') d <- data.frame('factor_1' = factor(c('a', 'a', 'b')), 'factor_2' = factor(c('1', '2', '1')), x = 1:3, y = 1:3) ggplot(data = d, mapping = aes(x = x, y = y)) + geom_point() + facet_grid(facets = factor_1 ~ factor_2, drop = TRUE) Obviously drop =

Move axis labels in between plot and facet strip

我与影子孤独终老i 提交于 2019-12-05 07:12:40
I am trying to move the facet strip to the far left of my plot, so that the labels sit adjacent to the bars, and the grouping strips sit to their left (see my example below). I assume this must be done with Grobs, but I have little experience with that level of manipulation and would appreciate guidance. Data: structure(list(dept = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L), .Label = c("Distribution Centre Services", "IT", "Marketing", "Merchandise &