-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWorking-With-Themes.Rmd
77 lines (55 loc) · 1.66 KB
/
Working-With-Themes.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
---
title: "Untitled"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(ggplot2)
```
### Working with Themes
```{r}
z <- ggplot(mtcars, aes(wt, mpg, colour = factor(cyl))) + geom_point(size=3)
z + theme(panel.background = element_rect(
fill = "lightblue"))
z + theme(legend.position = "none")
z + theme(panel.grid.minor = element_line(
colour = "red",
linetype = "dotted"))
```
```{r}
set.seed(1)
z <- rnorm(1000)
qplot(z, geom = "blank") +
geom_histogram(aes(y = ..density.., fill="green")) +
stat_density(geom = "line", aes(colour = "red")) +
stat_function(fun=dnorm, aes(x = z, colour = "blabla")) +
scale_colour_manual(name = "",
values = c("green", "blue"),
breaks = c("bla", "blabla"),
labels = c("kernel_est", "norm_curv"))
```
```{r}
set.seed(1)
z <- rnorm(1000)
qplot(z, geom = "blank") +
geom_histogram( aes(y=..density..),
breaks=seq(0,400,by=25),
colour="black",
fill="white") +
stat_function(fun=dnorm,
args=list(mean=mean(df$PF), sd=sd(df$PF)))+
labs(title="01. Distribuição percentual de demandas por PF",
y="Percentual")
```
```{r}
library(ggplot2)
ggplot(mtcars, aes(x = wt)) +
geom_histogram(aes(y = ..density..), fill = "red") +
stat_function(
fun = dnorm,
args = with(mtcars, c(mean = mean(wt),
sd = sd(wt)))
) +
scale_x_continuous("Miles per gallon") +
opts(title = "Histogram with Normal Curve")
```