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

416 questions
170
votes
6 answers

Annotating text on individual facet in ggplot2

I want to annotate some text on last facet of the plot with the following code: library(ggplot2) p <- ggplot(mtcars, aes(mpg, wt)) + geom_point() p <- p + facet_grid(. ~ cyl) p <- p + annotate("text", label = "Test", size = 4, x = 15, y =…
MYaseen208
  • 19,213
  • 32
  • 133
  • 260
49
votes
1 answer

Rotate switched facet labels in ggplot2 facet_grid

I would like to plot some barplots on top of each other using facet_grid: library(ggplot2) df <- group_by(mpg, manufacturer) %>% summarise(cty = mean(cty), hwy = mean(hwy)) %>% ungroup() df <- melt(df, id.vars = "manufacturer") ggplot() + …
roming
  • 915
  • 1
  • 7
  • 18
25
votes
5 answers

Draw a line at specific position/annotate a Facetgrid in seaborn

A have produced a boxplot with Facetgrid in seaborn the following way # Import the dataset tips = sns.load_dataset("tips") # Plot using FacetGrid, separated by smoke plt.style.use('ggplot') g = sns.FacetGrid(tips, col="smoker", size=5,…
BCArg
  • 1,484
  • 2
  • 13
  • 26
13
votes
2 answers

R : ggplot2 : facet_grid : how include math expressions in few (not all) labels?

I get stuck with something on ggplot2. I read most of the related posts, tried things but did not find any real solution. I want to include mathematical expressions in the label of my facet_grids with ggplot2. In the raw file, I cannot write the…
SkyR
  • 175
  • 1
  • 8
12
votes
2 answers

Repeating x axis labels for all facets using FacetGrid in seaborn

I am working with the FacetGrid example presented here that results in the plot below. In my data set, there is quite a lot of plots, and it would be convenient to have the x axis labels repeated for each facet, not only at the bottom. For this…
Krzysztof Słowiński
  • 2,959
  • 5
  • 27
  • 47
10
votes
1 answer

How to order data by value within ggplot facets

I have the following data frame: library(tidyverse) tdat <- structure(list(term = c("Hepatic Fibrosis / Hepatic Stellate Cell Activation", "Cellular Effects of Sildenafil (Viagra)", "Epithelial Adherens Junction Signaling", "STAT3 Pathway",…
scamander
  • 3,218
  • 3
  • 21
  • 49
10
votes
1 answer

ggplot2 outside panel border when using facet

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…
Guidofish
  • 103
  • 1
  • 1
  • 7
8
votes
1 answer

Free colour scales in facet_grid

Say I have the following data frame: # Set seed for RNG set.seed(33550336) # Create toy data frame loc_x <- c(a = 1, b = 2, c = 3) loc_y <- c(a = 3, b = 2, c = 1) scaling <- c(temp = 100, sal = 10, chl = 1) df <- expand.grid(loc_name =…
Lyngbakr
  • 9,482
  • 1
  • 29
  • 49
7
votes
2 answers

Is it possible to change the alignment of only 1 facet title

Say I have a facetted ggplot like this: data(iris) ggplot(iris, aes(x = Petal.Width, y = Sepal.Length)) + facet_grid(. ~ Species) + geom_point() Question: Is it possible to align only the 1st facet label ("setosa") to the left, but keep the…
morgan121
  • 1,989
  • 1
  • 12
  • 27
7
votes
1 answer

Multiple rows in facet_grid

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 =…
LukasKawerau
  • 931
  • 1
  • 17
  • 39
6
votes
1 answer

ggplot2 facet_grid with facet titles

Is there a canonical way to add facet titles within facet_grid? Or a way to specific row labels in facet_wrap? (Without geom_text, geom_label, or grob manipulation.) Consider: dat <- data.frame(rowInd = paste0("R", c(1, 2, 2, 3, 3, 3)), colInd =…
r2evans
  • 77,184
  • 4
  • 55
  • 96
6
votes
2 answers

How to create a FacetGrid stacked barplot using Seaborn?

I am trying to plot a facet_grid with stacked bar charts inside. I would like to use Seaborn. Its barplot function does not include a stacked argument. I tried to use FacetGrid.map with a custom callable function. import pandas as pd import seaborn…
rod41
  • 63
  • 7
6
votes
4 answers

Using facet tags and strip labels together in ggplot2

I'd like to create a figure using ggplot2's facet_grid, like below: # Load ggplot2 library for plotting library(ggplot2) # Plot dummy data p <- ggplot(mtcars, aes(mpg, wt)) p <- p + geom_point() p <- p + facet_grid(gear ~ cyl) print(p) This is…
Lyngbakr
  • 9,482
  • 1
  • 29
  • 49
6
votes
2 answers

Edit distance between the facet / strip and the plot

For example, library(ggplot2) ggplot(mpg, aes(displ, cty)) + geom_point() + facet_grid(cols = vars(drv)) How can I change the distance between the strip and the main plot? (For example, create a gap between the strip and the main plot.) But I…
Feng Tian
  • 1,461
  • 1
  • 14
  • 23
6
votes
1 answer

Seaborn FacetGrid PointPlot Label Data Points

Given the following: import seaborn as sns attend = sns.load_dataset("attention") sns.set_style("whitegrid", {'axes.grid' : False,'axes.edgecolor':'none'}) g = sns.FacetGrid(attend, col="subject", col_wrap=5, size=1.5, ylim=(0, 10)) ax =…
Dance Party2
  • 5,364
  • 11
  • 42
  • 88
1
2 3
27 28