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
4
votes
1 answer

Adding a subplot to each facet_wrap using same facet data

I try to add histogram suplots to each partial geom_sf plot of a facet_wrap plot based on the same data as in the respective facet_wrap plot. I have found some approaches via Google, but so far nothing concrete. My previous…
4
votes
1 answer

How to do ggplot2 facet_wrap on different pages?

I would need to plot 25 violin plots on different pages. ggplot(sum.tab_tall,aes(x=variable,y=value,fill=Genes))+ geom_violin()+ theme(axis.text.x = element_text(angle = 90))+ facet_wrap(~Genes,scales = 'fixed', nrow=3) With this code, I…
Jessica
  • 65
  • 1
  • 5
4
votes
0 answers

ggforce facet_wrap_paginate with number of plots not matching nrow and ncol

I have a problem with the facet_wrap_paginate function: I have several groups of diagrams. The number of diagrams in each group varies. When I use facet_wrap_paginate to plot each group in 5x4 diagrams onto one single pdf, I get an error if the last…
papan
  • 41
  • 2
4
votes
1 answer

ggplot using facet_wrap of multiple data.frame in R?

I am trying to ggplot D2 on the same figure as of D1. I, however, do not have data for the Variable X in D2 data.frame. How i can plot D2 on its respective facets of D1 plot? these plots represent data for 2011 and 2014 so i would like to have…
Hydro
  • 1,057
  • 12
  • 25
4
votes
0 answers

Is there a way to force geom_tile heatmap cells to be a specific size when generating a grid of heatmaps (using facet_wrap)?

In my Shiny data quality assessment application, users upload datasets and can generate reports using RMarkdown. One of those reports is a visual summary of the dataset, rating each variable of the dataset on three metrics: % Compliance (how well…
Judy
  • 102
  • 1
  • 5
4
votes
1 answer

Using secondary y-axis in ggplot2 with different scale factor when using facet_wrap

Suppose I have the following data: library(ggplot2) library(ggthemes) data = structure(list(origin = c("ARG", "ARG", "ARG", "ARG", "CHL", "CHL", "CHL", "CHL", "COL", "COL", "COL", "COL", "MEX", "MEX", "MEX", "MEX"), date = c(2012, 2013, 2014,…
Cristhian
  • 361
  • 3
  • 12
4
votes
2 answers

How can I have different geom_text() labels in a faceted, stacked bar graph in R with ggplot?

I am trying to use facet_wrap with stacked bar graphs, and I'd like to have labels on the bars showing the value of each part of the bar. Using the diamonds dataset as an example: My geom_text code works fine when there is only one graph, albeit…
4
votes
1 answer

Default panel layout of ggplot2::facet_wrap()?

I'm trying to understand the default behavior of ggplot2::facet_wrap(), in terms of how the panel layout is decided as the number of facets increases. I've read the ?facet_wrap help file, and also googled this topic with limited success. In one SO…
xilliam
  • 2,074
  • 2
  • 15
  • 27
4
votes
1 answer

Geospatial mapping using ggplot faceting in R?

I have a Watershed that has 33 subbasins. I wasn't able to come up with a code to draw a reproducible shapefile for the catchment so i am attaching my Shapefile. I have four models that generate Evapotranspiration (ET) data for the years 2005-2008.…
Hydro
  • 1,057
  • 12
  • 25
4
votes
1 answer

Create border and title for each column in `facet_wrap`

I want to put black borders with labels and titles around each facet in facet_wrap. Something similar to this: Sample data: library(tidyverse) mtcars %>% mutate(gear = factor(gear, levels = c(4, 3, 5))) %>% ggplot(aes(mpg, disp)) + …
DJV
  • 4,743
  • 3
  • 19
  • 34
4
votes
1 answer

How to Delete Facets from ggplot2 facet_wrap?

I am trying to use the package cregg through the examples here. The tutorial works well. However, after generating the plot with facetting, there must be a rightest column with the label NA. I have tried several ways but still cannot remove it. Can…
tzu
  • 183
  • 1
  • 9
4
votes
2 answers

Wrap multiple plots together in a single image

I am trying to wrap numerous plots together, as they are closely related (showing density using 1 continuous and 1 categorical variable, broken down by day of the week, where each day is a different plot). In R, I can either use grid.arrange() from…
SRVFan
  • 334
  • 1
  • 6
  • 16
4
votes
1 answer

Drawing a line down the centre mean of the density plots for EACH facet

Aim: I would like to draw a line down the mean for EACH individual facet. I currently have plotted a line for the mean of all facets: ggplot(mexi_sf, aes(FOODEXP)) + geom_density(alpha = 0.1,fill="red",colour="red") + …
delcast
  • 496
  • 1
  • 5
  • 16
4
votes
1 answer

Can I set dynamic axis limits in facet wrapped ggplot?

I have a dataset of ETAs and actual arrivals that I want to plot, so that I can compare the estimated times to the actual times. The challenge is that the ETAs lie close to the ATAs, but the ATAs lie far apart from one another. This is the plot I…
A. Stam
  • 2,148
  • 14
  • 29
4
votes
1 answer

ggplot2, facet_wrap: plotting data twice in different facets

Say I have a data frame like this: df <- data.frame(year_day = rep(1:365, 3), year = rep(2001:2003, each = 365), value = sin(2*pi*rep(1:365, 3)/365)) It represents some value (value) for each day of the year…
Dan
  • 11,370
  • 4
  • 43
  • 68