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

yhat ggplot facet_wrap type error

I have a pandas dataframe that I read in via txt file: training = pd.read_csv('training_data.txt') These are the columns: >> print training.columns.values` ['segment' 'cookie_id' 'num_visits' 'num_page_views'] I'm interested in a graph that…
skmathur
  • 1,587
  • 5
  • 14
  • 21
0
votes
1 answer

Specifying different axis labels between facets

I would like to specify the breaks and colors for two facets independently. Is there a way to do this? Using this code ggplot(data, aes(x = x, y = y)) + geom_point() + scale_y_continuous(breaks = c(0:3, 4, 6, 8)) + facet_wrap(~group,…
saladi
  • 3,103
  • 6
  • 36
  • 61
0
votes
1 answer

ggplot2: Show intervals in order specified by a vector and separate groups (e.g. with facet_wrap) using geom_pointrange() and coord_flip()

I have been trying to create a plot containing a comparison of "N1", "NON-N1" groups in a specific order. My data contains different groups called "A", "N1", "NON-N1", "Comb", and I am trying to show first the group with all called "A", then the…
jamespower
  • 15
  • 4
0
votes
0 answers

Different y-scales for different rows of facet_wrap

How can I have individual y-scales for every row of my facet_wrap plot? I tried scales="free_x" but that's not working. All y scales have the same max (see image). Any help is much appreciated! ggplot() + geom_bar(data=uws, aes(y =…
Stücke
  • 868
  • 3
  • 14
  • 41
0
votes
0 answers

Unable to display ggplot2 facet panels vertically or customise geom_bar colour

My data as per "dput(df)" output using Rstudio in Windows7ultimate system: > dput(df) structure(list(time = structure(c(5L, 2L, 8L, 4L, 1L, 7L, 3L, 6L), .Label = c("G1", "G1_S", "G2", "G2_M", "G2M_G1", "M", "S", "S_G2"), class = "factor"), RB1_total…
0
votes
0 answers

Overlaying proportional population trend on facet_wrap graphs displaying subset of data in R?

I have a set of player data from a game and I have it broken down into certain data for each of the 64 servers, after creating graphs for the overall game. I am using a facet_wrap to do the breakdown by server, and what I'd really like to be able to…
0
votes
0 answers

Only one factor on my x-axis is displayed with facet_wrap in ggplot

I am attempting to make a faceted barchart with each facet representing a sector of employment with three time points for each display. Here's my code and sample data Year <- c("2002", "2010", "2012", "2002", "2010", "2012", "2002", "2010",…
elmuertefurioso
  • 278
  • 1
  • 9
0
votes
0 answers

R ggplot2 facet wrap density plot

I'm using ggplot to create a facet wrap of histograms + density curves. This is the dataframe I'm plotting (~300 rows): head(merged) # tpl strand base score ipdRatio motif # 1 24501 0 A 51 3.108 AAGTACTCG # 2 58809 0 A …
alki
  • 3,334
  • 5
  • 22
  • 45
0
votes
1 answer

ggplot2 boxplot facet wrap

I am trying to use ggplot2 in R to construct a boxplot with different parameter sets in different panels or facets. In my input datatable, I have a column "process" which contains the parameter groupings. When I plot using facet_wrap, though, all…
ksw
  • 313
  • 3
  • 11
0
votes
1 answer

Adding top tick to y-axis in multi-panel plots (facet_wrap/ggplot2)

I have a multi-panel plots that I have created using facet_wrap function and I would like to add a top tick to each of the y-axis (so that each y-axis ends with a number). I can manually do this when I am creating one plot at a time with…
Joshlhj
  • 67
  • 1
  • 6
0
votes
0 answers

R, Incorrect output from ggplot2 and facet_wrap when using spatial data

I'm trying to create a visualisation of the UK for different time periods where the fill for each region depends on a numeric variable. When I split the dataframe by time period and create the charts independently in ggplot2, they are correct.…
Will_A
  • 1
  • 1
0
votes
0 answers

R - obscure ggplot2 error:

I have created a grouped data frame using dplyr: average_steps.i2 <- activity2 %>% group_by(Group, interval) %>% summarise(Average.Steps = mean(steps)) when I attempt to plot it, using ggplot ggplot(average_steps.i2 ,…
Bill Raynor
  • 413
  • 1
  • 4
  • 10
0
votes
1 answer

Dodged geom_errorbar with geom_bar using fill, colour, and alpha

I am attempting to make a facet_wrap bar_graph with error bars (se) that clearly shows three different categorical variables (Treatment, Horizon, Enzyme) with one response variable (AbundChangetoAvgCtl). Below is the code for some dummy data…
0
votes
1 answer

ggplot: geom_facet() by slope of geom_line()

Is there a way to facet_wrap() by the slope of a geom_line in R or ggplot, such that for each geom_line, all regions of that line with positive slope are placed in one facet, all regions with negative slope are placed in another facet, and all…
duhaime
  • 25,611
  • 17
  • 169
  • 224
0
votes
1 answer

How to set linetype for geom_vline in a faceted plot?

The following code works like a charm: foo = data.frame(x=c(1,2,3), y=c(4,5,6), lt=c('dotted', 'dashed', 'dotdash')) ggplot(foo, aes(x,y)) + geom_point() + geom_vline(aes(xintercept=x, linetype=lt)) The…
dfrankow
  • 20,191
  • 41
  • 152
  • 214