How to use ggplot2 encapsulated facet facet_wrap ()
This article mainly introduces the ggplot2 packaging facet facet_wrap () how to use, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
The use of ggplot2 encapsulated facet facet_wrap ()
Ggplot2 includes two types of facets, one is grid facet facet_grid, the other is encapsulated facet facet_wrap.
Grid facet is to generate a two-dimensional panel, the rows and columns of the panel are defined by variables. For more information, please see https://www..com/article/103, https://www..com/article/353.
The packaged cover is made into a 1-D panel and then packaged into 2-D.
Demonstrate the use of facet_wrap () with built-in data mpg, setting the form ~ a + b + c and modifying the default settings based on nrow and ncol
Library (ggplot2) > data (mpg) > print (mpg) # A tibble: 234 x 11 manufacturer model displ year cyl trans drv cty hwy fl 1 audi a4 1.8 1999 4 auto~ f 18 29 p 2 audi a4 1.8 1999 4 manu~ f 21 29 p 3 audi a4 2 2008 4 manu~ f 20 31 p 4 audi a4 2 2008 4 auto~ f 21 30 p 5 audi a4 2.8 1999 6 auto~ f 16 26 p 6 audi a4 2.8 1999 6 manu~ f 18 26 p 7 audi a4 3.1 2008 6 auto~ f 18 27 p 8 audi A 4 Q ~ 1.8 1999 4 manu~ 4 18 26 p 9 audi a 4 Q ~ 1.8 1999 4 auto~ 4 16 25 p 10 audi a 4 Q ~ 2 2008 4 manu~ 4 20 28 p # With 224 more rows, and 1 more variable: class > P print (P)
Generate small subgraph based on cly and drv variables, and set it to two lines
Thank you for reading this article carefully. I hope the article "how to use ggplot2 packaged facet facet_wrap ()" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!