/
71-split-screen-with-par-mfrow.Rmd
92 lines (56 loc) · 1.96 KB
/
71-split-screen-with-par-mfrow.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
---
title: "Use par mfrow to split screen"
descriptionMeta: "The par() function allows to set the mfrow() parameters to cut the charting window in several section."
descriptionTop: "The `par()` function allows to set the `mfrow()` parameters to cut the charting window in several section."
sectionText: "Scatter section"
sectionLink: "scatterplot.html"
DataToVizText: "Data to Viz"
DataToVizLink: "data-to-viz.com/graph/scatter.html"
url: "71-split-screen-with-par-mfrow"
output:
html_document:
self_contained: false
mathjax: default
lib_dir: libs
template: template_rgg.html
css: style.css
toc: TRUE
toc_float: TRUE
toc_depth: 2
df_print: "paged"
---
```{r global options, include = FALSE}
knitr::opts_chunk$set( warning=FALSE, message=FALSE)
```
<div class="container">
# Most basic scatterplot
***
<div class = "row">
<div class = "col-md-6 col-sm-12 align-self-center">
The `par()` function allows to set parameters to the plot. The `mfrow()` parameter allows to split the screen in several panels. Subsequent charts will be drawn in panels.
You have to provide a vector of length 2 to `mfrow()`: number of rows and number of columns.
<u>Note:</u> `mfcol()` does the same job but draws figure by columns instead of by row.
<u>Alternative</u>: see the [layout()](75-split-screen-with-layout.html) function for more complex layout creation.
</div>
<div class = "col-md-6 col-sm-12">
```{r thecode, echo=FALSE, out.width = "100%", fig.height=7}
#Create data
a <- seq(1,29)+4*runif(29,0.4)
b <- seq(1,29)^2+runif(29,0.98)
#Divide the screen in 2 columns and 2 lines
par(mfrow=c(2,2))
#Add a plot in each sub-screen !
plot( a,b , pch=20)
plot(a-b , pch=18)
hist(a, border=F , col=rgb(0.2,0.2,0.8,0.7) , main="")
boxplot(a , col="grey" , xlab="a")
```
</div>
</div>
```{r thecode, eval=FALSE}
```
<!-- Close container -->
</div>
```{r, echo=FALSE}
htmltools::includeHTML("htmlChunkRelatedCorrelation.html")
```