Using R version 3.6.2
Start the R repl.
Load your data.
Your data should be in the format of the attached foobar.csv
.
The first few columns are the X values suggested by the optimizer. Score is the Y value. Step is the, well, step. Step.quart is the quartile of the step.
states$step.quart <- as.factor(ntile(states$step, 4))
Then use this plotting code:
lower_continuous_plot <- function(data, mapping, ...) {
ggplot(data = data, mapping = mapping) +
geom_hex(..., bins = 4) +
scale_fill_viridis_c(option = "inferno")
}
lower_combo_plot <- function(data, mapping, ...) {
x.str <- str_remove(as.character(mapping["x"]), "~")
y.str <- str_remove(as.character(mapping["y"]), "~")
col.str <- str_remove(as.character(mapping["color"]), "~")
if (class(data[, x.str]) == "numeric") {
pp <- ggplot(data, mapping) +
geom_violin(aes_string(x = y.str, y = x.str, fill = col.str)) +
scale_fill_viridis_d() +
coord_flip()
} else {
pp <- ggplot(data, mapping) + geom_violin()
}
return(pp)
}
upper_combo_plot <- function(data, mapping, ...) {
ggplot(data = data, mapping = mapping) +
geom_point(..., aes(alpha = 0.4)) +
guides(alpha = F) +
scale_color_viridis_c(option = "viridis")
}
upper_continuous_plot <- function(data, mapping, ...) {
ggplot(data = data, mapping = mapping) +
geom_point(..., aes(alpha = 0.4)) +
guides(alpha = F) +
scale_color_viridis_c(option = "viridis")
}
diagnonal_continuous_plot <- function(data, mapping, ...) {
x.str <- str_remove(as.character(mapping["x"]), "~")
nbins <- length(unique(data[, x.str]))
ggplot(data = data, mapping = mapping) +
geom_histogram(..., aes(fill = step.quart), bins = nbins) +
scale_fill_viridis_d()
}
p <- ggpairs(states,
columns = which(colnames(states) %in% state.names),
aes(color = step, size = score),
lower = list(
continuous = lower_continuous_plot,
combo = lower_combo_plot
),
upper = list(
continuous = upper_continuous_plot,
combo = upper_combo_plot
# continuous = upper_continuous_plot,
# discrete = lower_discrete_plot,
# na = lower_discrete_plot
),
diag = list(
continuous = diagnonal_continuous_plot
),
legend = c(1, 2)
) + theme_bw()
Really nice, thanks @ekalosak!