Questions tagged [facet-grid]

Facet grid is a presentation form which includes panels defined by facetting variables. Facet grid is allowed to show all existed combinations of the concerned variables to reveal relationships between them.

Facet grid is a presentation form which includes panels defined by facetting variables. Facet grid is allowed to show all existed combinations of the concerned variables to reveal relationships between them.

Some graph packages have facet grid plotting tools:

: ggplot2 facet_grid examples

: seaborn FacetGrid examples

642 questions
3
votes
0 answers

annotate facet_grid plot with two-way ANOVA post-hoc results

I have a 2x2 study design (i.e. 4 groups) to test the interaction of two different interventions, and obtain multiple measurements for each subject, measured across different sites. I can nicely plot these data using a facet_grid for the different…
Timmo83
  • 119
  • 5
3
votes
2 answers

How to overlay data points on a barplot with a categorical axis

Goal: I am trying to show individual data points in a figure with multiple grouped bar charts using Seaborn. Problem: I tried to do it with a catplot for the bar chart and another catplot for the individual data points. However, this generates 2…
Alex Schubert
  • 67
  • 2
  • 7
3
votes
1 answer

How to customize text in ggplot2 facet_grid label when using purrr?

I am using purrr and ggplot2 to create multiple plots at once. For each facet's name, I want to keep the group's name, but I also want to add the number of participants in each sub-group. For instance, "Manager (N = 200)" and "Employee (N = 3000)".…
J.Sabree
  • 2,280
  • 19
  • 48
3
votes
1 answer

Assign custom colors to each plot of facet_wrap histograms in R - ggplot

I want to use facet_wrap in R to split my plots based on a certain column. Here is a working example I reproduced from here: set.seed(1) df <- data.frame(age = runif(500, min = 10, max = 100), group = rep(c("a", "b", "c", "d", "e"),…
mah65
  • 578
  • 10
  • 20
3
votes
1 answer

geom_col with facet_grid with margins=TRUE not stacking up?

The bars in the margins appear to be picking the maximum facet rather than summing them up as I expected. Shouldn't they be stacking up in the margins? Is this a bug? Any suggestions how I might change geom_col / geom_bar / position settings, or a…
Arthur Yip
  • 5,810
  • 2
  • 31
  • 50
3
votes
1 answer

Adding total histogram count to facets in ggplot in R

I would like to take a faceted histogram and add text on each plot indicating the total number of observations in that facet. So for carb = 1 the total count would be 7, carb = 2 the total count would be 10 etc. p <- ggplot(mtcars, aes(x = mpg, stat…
melani
  • 43
  • 4
3
votes
1 answer

How to place the strip in facet_grid on top of plots when plotting graphs vertically stacked - similar to position.strip = "top" in facet_wrap?

Using facet_grid(), how can I place the group names, i.e. the grey strips, on the top of the plots when graphing the plots stacked vertically in a single column? From what I have tried, when stacking the plots vertically, using facet_grid(), you…
3
votes
1 answer

Ordering Facets in a plot based on a column in the dataset

So, I have a dataset which looks like this. I'm tasked with creating a smooth faceted visualization which shows each coral's bleaching rate at each site which I've successfully done so like this: (I FULLY realize that this code might be bad and have…
dealvidit
  • 45
  • 6
3
votes
1 answer

Using facet_grid to plot multiple spatial polygons with common polygon as overlay

I want to plot spatial data from a SpatialPolygonDataframe. More specifically I want to plot single spatial features in single subplots using facet_grid() of ggplot2. In addition I'd like to plot a common spatial polygon as overlay in each of the…
Johannes
  • 1,024
  • 13
  • 32
3
votes
2 answers

Labelling plots arranged with grid.arrange

I have attached multiple plots to one page using grid.arrange. Is there a way to label each plot with "(a)","(b)" etc... I have tried using geom_text but it does not seem compatible with my plots.... .... as you can see, geom_text has some strange…
Eliott Reed
  • 351
  • 1
  • 4
  • 12
3
votes
0 answers

Is there a row equivalent to the 'col_wrap' parameter in seaborn's FacetGrid?

I am making a ridge plot using seaborn in python (following this example). In my case however, I have a lot more than 10 distributions, so I'd like to have multiple columns of histograms. This all gets set up using this FacetGrid command: g =…
Chris Gordon
  • 191
  • 3
  • 13
3
votes
2 answers

R - stat_compare_means return differnt value from Kruskal-Wallis test

I want to plot the p value of Kruskal-Wallis test to my ggplot using the R function stat_compare_means from the package ggpubr. However, the plotted value is different from the value if I simply run the function: kruskal.test(value ~ type, data =…
DigiPath
  • 179
  • 2
  • 10
3
votes
1 answer

How to reposition title in seaborn.FacetGrid if tight_layout is applied?

I have a simple seaborn FacetGrid() with barplots inside. I applied tight_layout() to my final plot, as xticks had to be properly positioned on the plot after rotation. As result, when I want to add the title to the plot it is positioned in the…
3
votes
1 answer

How do i add shading to nighttime with geom_rect without facet scales expanding?

I have a dataframe with with a value measured with an instrument at four locations over consecutive time periods. I wish to have the night time (6pm to 6am) shaded grey to help with interpretation. The code below plots this correctly except i also…
Jordan
  • 173
  • 1
  • 2
  • 9
3
votes
1 answer

How do I order x-axis within facet_nested

I have created a barplot and arranged the x-axis accordingly to how I want it. However, once I run it through facet_nested, it changes the order. This is what my file looks like: file: drug P_resistant G_resistant DrugA 18 …
cms72
  • 177
  • 10