-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.R
43 lines (34 loc) · 1.01 KB
/
test.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
#### Test ####
# Install oiplot
devtools::install_github("OpportunityInsights/oiplot")
# Load the oiplot and ggplot2 packages
library(oiplot)
library(ggplot2)
# Setting default OI Facebook Palette
set_oi_palette()
# Create the scatter plot
scatter_plot <- ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point(size = 2, alpha = 0.8) +
geom_smooth() +
labs(
x = "Weight", y = "Miles Per Gallon",
title = "Scatterplot of Car Weight vs. MPG"
) +
oi_style()
# Print the plot
scatter_plot
## OI Facebook Colour Scheme
fb_palette <- c(
"#29B6A4", "#FAA523", "#003A4F", "#7F4892", "#A4CE4E",
"#2B8F43", "#0073A2", "#E54060", "#FFD400", "#6BBD45"
)
scatter_plot <- ggplot(mtcars, aes(x = wt, y = mpg, colour = as.factor(cyl))) +
geom_point(size = 2, alpha = 0.8) +
geom_smooth() +
labs(
x = "Weight", y = "Miles Per Gallon",
title = "Scatterplot of Car Weight vs. MPG"
) +
oi_style() +
scale_colour_manual(values = fb_palette) # Apply the color scale manually to the plot
print(scatter_plot)