-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathantideriv.R
95 lines (78 loc) · 2.36 KB
/
antideriv.R
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
93
94
95
library(tidyverse)
theme_set(theme_bw())
dir.create("antideriv_pics")
x_lines <- seq(-3, 3, length.out = 20) %>% round(3)
tibble(x = seq(-3, 3, by = .001),
func = dnorm(x),
integral = pnorm(x)) -> antideriv_data
tibble(x = x_lines,
y = pnorm(x)) -> antideriv_points
# i = 3
for (i in 1:20) {
gridExtra::grid.arrange(
antideriv_data %>%
ggplot(aes(x, integral)) +
# geom_area(
# data = antideriv_data %>% filter(x < x_lines[2]),
# fill = "royalblue",
# alpha = .5
# ) +
geom_line(size = 1) +
geom_vline(xintercept = x_lines[i],
color = "royalblue") +
annotate(
geom = "point",
x = x_lines[i],
y = antideriv_points$y[i],
size = 2,
color = "royalblue"
) +
# # facet_wrap(~ name, nrow = 2, scales = "free_y") +
labs(y = "F(x)"),
antideriv_data %>%
ggplot(aes(x, func)) +
geom_area(
data = antideriv_data %>% filter(x < x_lines[i]),
fill = "royalblue",
alpha = .5
) +
geom_line(size = 1) +
geom_vline(xintercept = x_lines[i],
color = "royalblue") +
# facet_wrap(~ name, nrow = 2, scales = "free_y") +
labs(y = "f(x)")
) -> current_plot
ggsave(paste0("antideriv_pics/antideriv", i, ".png"), current_plot)
}
# antideriv_data %>%
# ggplot(aes(x, integral)) +
# # geom_area(
# # data = antideriv_data %>% filter(x < x_lines[2]),
# # fill = "royalblue",
# # alpha = .5
# # ) +
# geom_line(size = 1) +
# geom_vline(xintercept = x_lines[i],
# color = "royalblue") +
# annotate(geom = "point",
# x = x_lines[i],
# y = antideriv_points$y[i],
# size = 2,
# color = "royalblue") +
# # # facet_wrap(~ name, nrow = 2, scales = "free_y") +
# labs(y = "Value"),
#
# antideriv_data %>%
# ggplot(aes(x, func)) +
# geom_area(
# data = antideriv_data %>% filter(x < x_lines[i]),
# fill = "royalblue",
# alpha = .5
# ) +
# geom_line(size = 1) +
# geom_vline(xintercept = x_lines[i],
# color = "royalblue") +
# # facet_wrap(~ name, nrow = 2, scales = "free_y") +
# labs(y = "Value")
# ggsave("pics/antideriv.png", antideriv)
# ggsave("pics/antideriv.svg", antideriv)