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
220
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
  • 22,666
  • 37
  • 165
  • 309
143
votes
7 answers

How to add a title to Seaborn Facet Plot

How do I add a title to this Seaborne plot? Let's give it a title 'I AM A TITLE'. tips = sns.load_dataset("tips") g = sns.FacetGrid(tips, col="sex", row="smoker", margin_titles=True) g.map(sns.plt.scatter, "total_bill", "tip")
collarblind
  • 4,549
  • 13
  • 31
  • 49
132
votes
2 answers

How to set the xlim and ylim of a FacetGrid

I'm using sns.lmplot to plot a linear regression, dividing my dataset into two groups with a categorical variable. For both x and y, I'd like to manually set the lower bound on both plots, but leave the upper bound at the Seaborn default. Here's a…
exp1orer
  • 11,481
  • 7
  • 38
  • 51
67
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
  • 1,165
  • 1
  • 9
  • 22
43
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
  • 2,094
  • 2
  • 19
  • 37
30
votes
1 answer

Prevent sharing the y-axis in a relplot

I'm having trouble getting seaborn's relplot function to plot with different y axes on each row (while sharing x axes per column). I can see that both the FacetGrid and catplot methods in seaborn have a sharex/sharey keyword argument that would…
Sooraj Achar
  • 313
  • 3
  • 5
30
votes
3 answers

FacetGrid change titles

I am trying to create a FacetGrid in Seaborn My code is currently: g = sns.FacetGrid(df_reduced, col="ActualExternal", margin_titles=True) bins = np.linspace(0, 100, 20) g.map(plt.hist, "ActualDepth", color="steelblue", bins=bins, width=4.5) This…
jlt199
  • 2,349
  • 6
  • 23
  • 43
29
votes
1 answer

seaborn is not plotting within defined subplots

I am trying to plot two displots side by side with this code fig,(ax1,ax2) = plt.subplots(1,2) sns.displot(x =X_train['Age'], hue=y_train, ax=ax1) sns.displot(x =X_train['Fare'], hue=y_train, ax=ax2) It returns the following result (two empty…
callmeanythingyouwant
  • 1,789
  • 4
  • 15
  • 40
21
votes
1 answer

Increase space between rows on FacetGrid plot

I've the following code which creates the plot you can see in the picture: g = sns.FacetGrid(data, col="Provincia",col_wrap=6,size=2.5) g.map(sns.barplot, "Anio", "Diff"); g.set_axis_labels("Año", "Porcentaje de aumento"); for ax in g.axes.flat: …
Rod0n
  • 1,019
  • 2
  • 14
  • 33
19
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
  • 6,239
  • 8
  • 44
  • 62
17
votes
3 answers

Overlay a line function on a scatter plot - seaborn

My challenge is to overlay a custom line function graph over a scatter plot I already have, the code looks like follows: base_beta = results.params X_plot = np.linspace(0,1,400) g = sns.FacetGrid(data, size = 6) g = g.map(plt.scatter,…
Svarto
  • 603
  • 2
  • 8
  • 20
15
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",…
littleworth
  • 4,781
  • 6
  • 42
  • 76
14
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
  • 185
  • 1
  • 9
14
votes
2 answers

Facetgrid change xlabels

I just can't figure out how to change the xlabels in a Seaborn FacetGrid. It offers a method for changing the x labels with set_xlabels() but unfortunately not individually for each subplot. I have two subplots which share the y-axis but have a…
J-H
  • 1,795
  • 6
  • 22
  • 41
12
votes
1 answer

How to add individual vlines to every subplot of seaborn FacetGrid

I want to add a vertical line to every subplot to mark the individual launch date of each product. Every vertical line should display the date. But i am too beginner to figure this out. I tried .axvline as an example: Here is the code: g =…
Zeno
  • 123
  • 1
  • 5
1
2 3
42 43