-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path09-06-layers-position-adjustments.qmd
71 lines (49 loc) · 1.63 KB
/
09-06-layers-position-adjustments.qmd
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
# Layers
# Position Adjustments
```{r}
#| output: false
library(tidyverse)
```
> 1. What is the problem with the following plot? How could you improve it?
```{r}
ggplot(mpg, aes(x = cty, y = hwy)) +
geom_point()
```
I'm gonna say sight unseen that we have a really small variance in x, meaning
that we have overlapping values.
Boy was I right. Let's add some transparency:
```{r}
ggplot(mpg, aes(x = cty, y = hwy)) +
geom_point(alpha = 0.6, color = "#6994d1")
```
Now let's jitter the points:
```{r}
ggplot(mpg, aes(x = cty, y = hwy)) +
geom_point(alpha = 0.6, color = "#6994d1", position = "jitter")
```
> 2. What, if anything, is the difference between the two plots? Why?
```{r}
ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point()
ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point(position = "identity")
```
Oh I bet these are the same. I'm almost certain the default value for
`position` with a scatter plot is "identity".
> 3. What parameters to `geom_jitter()` control the amount of jittering?
`width` and `height`. They are proportions of the resolution of the data, which
is to say the differences between them. I think that means that for more
continuous data, they move less.
> 4. Compare and contrast `geom_jitter()` with `geom_count()`.
Well, one shows overplotting on a scatter by moving, and the other by
increasing the size of the points.
> 5. What’s the default position adjustment for `geom_boxplot()`? Create a
> visualization of the mpg dataset that demonstrates it.
The default value is `position_dodge2`.
```{r}
ggplot(mpg) +
geom_boxplot(
aes(x = cty, y = hwy, group = cyl),
position = "identity"
)
```