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
4
votes
2 answers

How to add a comparison line to all plots when using Seaborn's FacetGrid

I'm trying to add the same comparison line to multiple plots using FacetGrid. Here is where I get stuck: # Import the dataset tips = sns.load_dataset("tips") # Plot using FaceGrid, separated by smoke g = sns.FacetGrid(tips, col="smoker", size=5,…
rmc33
  • 65
  • 1
  • 5
4
votes
2 answers

Add both margins to facet_grid but not the combination

I want to show both the right and the bottom margin, but not the combination of both. Is this possible with facet_grid? library(ggplot2) ggplot(mtcars, aes(x = hp, group = vs)) + geom_density() + facet_grid(am ~ vs, switch = "y", margins =…
4
votes
1 answer

ggplot2 facet_grid create panels on the y-axis

I have similar data like the following example: dat1 <- data.frame(group=c("a", "a","a", "a","a","a","b","b","b","b","b", "b", "b","b","b","c","c","c","c","c","c"), subgroup=c(paste0("R", rep(1:6)),paste0("R",…
4
votes
1 answer

ggplot: How to create different x-axis titles with facet_grid

I have two plots that share the y-axis but have different x-axes. I used facet_grid to separate them appropriately (see figure), but the two x-axes need to have different titles (instead of the one title "Num Cell Lines.Tissue"). I've seen something…
bashmike
  • 73
  • 1
  • 2
  • 8
4
votes
1 answer

autocrop faceted plots made by ggplot

When making faceted plots in ggplot and changing the aspect ratio, usually there is a lot of white space either left and right or above and below the graph. E.g: library(ggplot2) df <- data.frame(x=rep(1,3), y=rep(1,3), z=factor(letters[1:3])) p <-…
WJH
  • 539
  • 5
  • 14
4
votes
1 answer

Plotting mean lines for different 'hue' data on a Seaborn FacetGrid plot

I am working with the Titanic passenger dataset (from Kaggle) as part of a Udacity course. I am using a Seaborn FacetGrid to look at passenger age distribution profiles by Travel class and Gender - with hue as 'Survived' (1/0). The plot is working…
chrisrb10
  • 189
  • 1
  • 3
  • 12
4
votes
1 answer

ggplot combine line and area in same panel (facet-grid)

I am trying to create a facet grid. It will have three rows and four columns. I want two rows to be line graphs, and one to be a stacked geom_area. Except when I plot this, It always turns up as four rows- two lines, two areas. I would like the…
Valerie S
  • 917
  • 2
  • 7
  • 17
3
votes
2 answers

Left Align the Titles of Each Plotly Subplot

I have a facet wraped group of plotly express barplots , each with a title. How can I left align each subplot's title with the left of its plot window? import lorem import plotly.express as px import numpy as np import random items =…
Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519
3
votes
2 answers

Free axis along particular facets in facet_grid ggplot

I am trying to do 2 things: First and most important is to somehow get the y axis to vary by the outcome_type2 variable, since they all have fairly different ranges. So the "C" have their own axis range, the "Z" have their own axis range, and the…
a_todd12
  • 449
  • 2
  • 12
3
votes
2 answers

Move titles of ggplot2 object with facet_grid to the middle

I have the following dataframe: ML Algorithm Option Coeff Lower Upper 1 Random Forest Algo_1 Opt_1 0.021 -0.124 0.166 2 Lasso Algo_1 Opt_1 0.130 -0.012 0.273 3 XGBoost Algo_1 Opt_1 -0.052 -0.211 …
miamialan
  • 53
  • 5
3
votes
2 answers

Vector of 2 Different Greek Symbols on Ggplot Grid Label

I want to place the following in the same order \phi = 0.4, \theta = 0.4 in column 1 \phi = 0.45, \theta = 0.45 in column 2 and \phi = 0.35, \theta = 0.5 in column 3 library(reshape2) set.seed(199) ARMA11_MAE_MBB_sd1_psi0.8 <- runif(4, min = 0, max…
Daniel James
  • 1,381
  • 1
  • 10
  • 28
3
votes
1 answer

Adjust facet width by different number of groups in grouped barplot

I'd like to facet_wrap some geom_bar graphs that have the same number of groups on the y-axis, but a different number of "dodged" groups on each x-axis category. While I can adjust the width of bars on the graph so they are the same between facets,…
Timmo83
  • 119
  • 5
3
votes
1 answer

Legend issues when mapping plot to FacetGrid

I've also opened an issue in the seaborn git repo here. However, instead of a bug, it's quite possible that instead I'm making some basic error - but I haven't figured it out yet... Question: The same color is assigned to two different values in the…
Ben
  • 958
  • 6
  • 7
3
votes
2 answers

Add unique horizontal line for levels in facet_grid

I want to add a unique horizontal line across each row of a set of facet grid boxplots. x<-c("species_X","species_X","species_X", "species_Y","species_Y", "species_Y", "species_Z", "species_Z", "species_Z") y<- c(1,2,3) df<-…
hugh_man
  • 399
  • 1
  • 6
3
votes
1 answer

pasting with glue::glue changes order of values in facet

Based on this response How to add greek letters to Facet_Grid strip labels? , I successfully create a ggplot with greek letters in the facet label. However the glue library changes the order of my label FacetX, how can I deal with it? This is an…
Sle R.
  • 87
  • 7