Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separate y axis for different facets in ggplot

Tags:

r

ggplot2

I would like to create a plot using ggplot where different facets should have different y axis limits. By default each facet has the same y axis values. can this be changed somehow?

like image 849
user1723765 Avatar asked Dec 03 '13 16:12

user1723765


People also ask

How do you remove facet labels?

Facet labelsSetting strip. text to element_blank() will remove all facet labels. You can also remove the labels across rows only with strip. x.

How do I increase space between facets in ggplot2?

To increase the space between facets in a facetted plot created by using ggplot2 in R, we can use theme function with panel. spacing argument.

What is the function of Facet_grid () in Ggplot ()?

facet_grid() forms a matrix of panels defined by row and column faceting variables. It is most useful when you have two discrete variables, and all combinations of the variables exist in the data.

What is facet wrap in ggplot2?

facet_wrap() makes a long ribbon of panels (generated by any number of variables) and wraps it into 2d. This is useful if you have a single variable with many levels and want to arrange the plots in a more space efficient manner. You can control how the ribbon is wrapped into a grid with ncol , nrow , as.


1 Answers

You can change scales to "free_y" instead.

  facet_grid(facets, margins = FALSE, scales = "fixed",
    space = "fixed", shrink = TRUE,
    labeller = "label_value", as.table = TRUE, drop = TRUE)

For further detail and examples, see: http://docs.ggplot2.org/0.9.3.1/facet_grid.html

like image 144
Steph Locke Avatar answered Sep 30 '22 16:09

Steph Locke