Questions tagged [facet-wrap]

In R graphics system ggplot2, facet_wrap is a way to wrap a 1d ribbon of panels into 2d shape. Typically, it groups a data set by one or more categorical variables or variables coercible to factor and plots one data group per panel using the same aesthetics mappings.

In R graphics system ggplot2, facet_wrap is a way to wrap a 1d ribbon of panels into 2d shape. Typically, it groups a data set by one or more categorical variables or variables coercible to factor and plots one data group per panel using the same aesthetics mappings.

Resources for using facet_wrap:

873 questions
0
votes
1 answer

R using facet_wrap for selected categories

I am trying to use facet_wrap to plot indvidual plots. library(lme4) library(dplyr) library(tibble) # Convert to tibble for better printing. Convert factors to strings sleepstudy <- sleepstudy %>% as_tibble() %>% mutate(Subject =…
user53020
  • 889
  • 2
  • 10
  • 33
0
votes
1 answer

facet_wrap with different factor levels in each subplot

Is there any possibility to remove "f e d" levels from the first subplot and "c b a" from the second subplot using facet_wrap? In other words I want to have only "c b a" columns on first subplot and only "f e d" columns on the 2nd. Example…
knst4444
  • 88
  • 1
  • 4
0
votes
0 answers

Faceting in rankabunplot

A follow-up to how to add specnames to rankabuncomp? The following code, from user Jari Oksanen helped to plot curves one by one, on the same plane. library(BiodiversityR) data(dune, dune.env) ## list of models mods <- with(dune.env,…
Little Bee
  • 1,175
  • 2
  • 13
  • 22
0
votes
1 answer

How to create facet plot from hierarchically grouped data frame

I have the following tibbles s12.tbl and ref.tbl. s12.tbl <- structure(list(Sample_name = c("s1", "s2", "s1", "s2", "s1", "s2", "s1", "s2", "s1", "s2", "s1", "s2", "s1", "s2", "s1", "s2", "s1", "s2", "s1", "s2"), some_score = c("0.04741",…
neversaint
  • 60,904
  • 137
  • 310
  • 477
0
votes
2 answers

Play graphic of ggplot2 using multiple facets

I built the graph below using the command grid.arrange from the gridExtra package, would like to leave it with the visuals of the multi-facets graphs, using the samples size as facet, is it…
fsbmat
  • 291
  • 3
  • 12
0
votes
1 answer

R Changing Titles For Facets In Grid Arrange

I am trying to change the titles for each facet of this grid arranged plot. Everything I have been trying either makes each title "Atlantic" or gives an error. The problem is that I needed to make some divisions one word so they can be variables,…
Remy M
  • 599
  • 1
  • 4
  • 17
0
votes
2 answers

Smart association of graphs where one is faceted - ggplot2

I want to combine these two graphs : p1 <- ggplot(iris, aes(Sepal.Length)) + geom_density() + facet_wrap(~ Species) p2 <- ggplot(iris, aes(Sepal.Length)) + geom_density() To combine, I do : multiplot(p1, p2, cols = 2) But it is not the…
Loulou
  • 703
  • 5
  • 17
0
votes
1 answer

How can we create multiple density plots in ggplot2 by keeping one density plot as constant (in all facets) for the comparison scenario?

I have the data of speeds associated different types of vehicles (lets say, Car, Motorcycle, Truck, Bus etc) and I want to show how the speed of these different types of vehicles differs when we compare to speed of car. For example: In above…
0
votes
0 answers

How to subset or remove rows in facet_wrap (ggplot2)?

I have a long formatted data-frame where I plotted histograms for each person's data using facet_wrap(). But I would like to remove a histogram for a person numbered 106. How can I do this in facet_wrap() function without needing to go back and…
0
votes
0 answers

How to remove a facet from facet_wrap in R -ggplot2

I have the following data set: here is a sample Date Site Flow 14/10/2014 B1 NA 28/10/2014 B1 NA 31/10/2014 B1 0.118433346 04/11/2014 B1 NA 10/11/2014 B1 NA 18/11/2014 B1 NA 25/11/2014 B1 NA …
LucySHE
  • 387
  • 1
  • 3
  • 9
0
votes
0 answers

ggplot2: Different vlines for each graph using facet_wrap

I'm working in R and i've a problem using facet_wrap(). I'm trying to put 3 vlines for each graph generate facets but i can't. Each vline represent the mean, median and 75th percentile, and i saved them in a simple vector, like this: >…
Felipe Piña
  • 89
  • 1
  • 2
  • 11
0
votes
0 answers

Level-dependent axis vales using facet_wrap

I have a dataframe so: >head(so) tri trans freq sample 1 ACA C=>T 13 S1 2 ACC C=>T 9 S1 3 ACG C=>T 6 S1 4 ACT C=>T 14 S1 5 CCA C=>T 24 S1 6 CCC C=>T 16 S1 >tail(so) tri trans freq sample 59 GGG …
fugu
  • 6,417
  • 5
  • 40
  • 75
0
votes
0 answers

geom_text() label statistics printing on top of each other in each facet of plot

I have a faceted plot of probability distributions (histogram of y=..density.. with binwidth=1) as produced below. library(ggplot2) library(sqldf) data(iris) #Create Binned(Factor) Versions of Continuous Variables iris$Sepal.Length =…
Max Power
  • 8,265
  • 13
  • 50
  • 91
0
votes
1 answer

Adding different vertical lines on facets ggplot2

I am quite a newbie to RStudio and I am having problems adding different vertical lines on each of my two facets using facet_wrap Here is what I thought: library(ggplot2) g <- ggplot(dat, aes(x=index, na.rm= TRUE)) d <- g+ geom_density() +…
amyk
  • 9
  • 3
0
votes
2 answers

Add axis to ggplot facet_wrap histograms

I'm trying to create a series of histograms with the same range on the axis and crucially axis that lie at zero intercepts for both x and y mydat1 <- mydat + geom_histogram(binwidth = 5) + facet_wrap(~V2, scales = "free") + theme(axis.line.x =…
Tim
  • 3
  • 1