-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheatmap_test_Rs.R
More file actions
33 lines (26 loc) · 1.04 KB
/
heatmap_test_Rs.R
File metadata and controls
33 lines (26 loc) · 1.04 KB
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
require(ggplot);
# run this script for heatmap plot in morden R# language
setwd(@dir);
spinrates <- read.csv("../data/spinrates.csv",
stringsAsFactors = FALSE);
spinrates[, "swing_miss"] = as.numeric(spinrates$swing_miss);
print(spinrates);
let ggplot2 = function() {
p <- ggplot(spinrates, aes(x = "velocity", y = "spinrate"),padding = "padding:10% 10% 10% 12%;") +
geom_tile(aes(fill = "swing_miss")) +
scale_fill_distiller(palette = "rev(ggthemes::excel_Vapor_Trail)", direction = 1) +
theme_light(
axis.text = element_text(family = "Cambria Math", size = 20),
axis.title = element_text(family = "Cambria Math", size = 36),
legend.tick = element_text(family = "Cambria Math", size = 18)
) +
labs(title = "Likelihood of swinging and missing on a fastball",
y = "spin rate (rpm)");
p;
}
png(filename = "./test_heatmap.png", width = 2000, height = 1200);
plot(ggplot2());
dev.off();
svg(file = "./test_heatmap.svg", width = 1600, height = 800);
plot(ggplot2());
dev.off();