-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchart_functions.r
70 lines (65 loc) · 1.5 KB
/
chart_functions.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
# Compare Per1000Jobs by location
makeplot_per1000ByLocation <- function (data_to_plot) {
return (
ggplot(
data_to_plot,
aes(
x=reorder(Location, -Per1000Jobs),
y=Per1000Jobs,
fill=(Location == wichita_area_name)
)
) +
geom_col() +
ylab('Developer Jobs Per 1000 Jobs') +
xlab('') +
theme(legend.position = 'none', axis.text = element_text(size=12)) +
coord_flip()
)
}
makeplot_salaryByLocation <- function(data_to_plot, rpp=FALSE, error = 0.03) {
if (rpp) {
base_plot <- ggplot(
data_to_plot,
aes(
x=reorder(Location, -RppAdjSalary),
y=RppAdjSalary,
fill=(Location == wichita_area_name)
)
)
error_bars <- geom_errorbar(
aes(
x=Location,
ymin=(1-error) * RppAdjSalary,
ymax=(1 + error) * RppAdjSalary
),
width = 0.2
)
} else {
base_plot <- ggplot(
data_to_plot,
aes(
x=reorder(Location, -MeanSalary),
y=MeanSalary,
fill=(Location == wichita_area_name)
)
)
error_bars <- geom_errorbar(
aes(
x=Location,
ymin=(1-error) * MeanSalary,
ymax=(1 + error) * MeanSalary
),
width = 0.2
)
}
return (
base_plot +
geom_col() +
ylab(if (rpp) 'RPP-Adjusted Salaries' else 'Mean Salaries') +
xlab('') +
scale_y_continuous(label=comma) +
theme(legend.position = 'none', axis.text = element_text(size=12)) +
coord_flip() +
error_bars
)
}