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()
This is the expected result.
The diagonal is the marginal frequency of each X in the optimization run. The lower triangle is similar - a 2d marginal frequency. The upper triangle is the sequence of steps, as described by the legend on the rhs. Diagonal plots for continuous variables show, via color, the proportion of samples at that x-value suggested at a particular step.quantile.