Advanced Visualization (TODO)
advanced_visualization.Rmd
This vignette will cover advanced visualization options, overlays, manual layers, and animations. Most of this section is a placeholder and will be expanded in future versions.
Surface Visualization Options
You can customize the appearance using the theme system:
viz = as_visualizer(obj("TF_franke"), type = "surface")
viz$plot(theme = list(palette = "grayscale"))
The add_contours()
method allows you to add custom
contour lines to the surface:
Setting the layout and scene
You can customize layout and scene directly in the
plot()
method:
viz = as_visualizer(obj("TF_franke"), type = "surface")
viz$plot(layout = list(
title = list(text = "Custom Title", font = list(size = 20)),
showlegend = TRUE
))
Overlaying layers (TODO)
obj = obj("TF_banana")
# Use surface visualizer for surface features like surface, taylor, and hessian layers
viz = as_visualizer(obj, type = "surface")
x0 = c(0.85, 0.47)
viz$add_taylor(x0, npoints_per_dim = 5, degree = 1, x1margin = 0.3, x2margin = 0.3, contours = list(
x = list(show = TRUE, start = 0, end = 1, size = 0.03, color = "black"),
y = list(show = TRUE, start = 0, end = 1, size = 0.03, color = "black")
))
viz$add_hessian(x0)
viz$plot()
Manual layers (TODO)
obj = obj("TF_banana")
viz = as_visualizer(obj, type = "surface")
viz$set_theme(vistool_theme(alpha = 0.4))
p = viz$plot()
class(p)
#> [1] "plotly" "htmlwidget"
nsim = 100
grid = data.frame(x = runif(nsim), y = runif(nsim))
grid$z = apply(grid, 1, viz$objective$eval) + rnorm(nsim, sd = 0.05)
p %>% add_trace(
data = grid, x = ~x, y = ~y, z = ~z, mode = "markers",
type = "scatter3d", marker = list(symbol = "cross")
)
ggplot2 Backend
You can use the ggplot2 backend for 2D objectives:
viz = as_visualizer(obj("TF_franke"))
viz$plot()
Further customization:
library(ggplot2)
viz = as_visualizer(obj("TF_franke"))
p = viz$plot()
p + labs(title = "TF Franke Function")