Visualize 2D Functions as Interactive Surfaces
VisualizerSurface.Rd
Visualizes a two-dimensional function \(f: \mathbb{R}^2 \to \mathbb{R}\) via interactive plotly renderings. Creates 3D surface and contour plots for better visualization of 2D functions.
Super class
vistool::Visualizer
-> VisualizerSurface
Public fields
grid
(`list()`)
List with the `x1` and `x2` grid.zmat
(`matrix()`)
The result of evaluation at each element of the cross product of `grid$x1` and `grid$x2`.plot_lab
(character(1)
Label of the plot.x1_lab
(character(1)
Label of the x1 axis.x2_lab
(character(1)
Label of the x2 axis.z_lab
(character(1)
Label of the z axis.
Methods
Method new()
Creates a new instance of this [R6][R6::R6Class] class.
Usage
VisualizerSurface$new(
grid,
zmat,
plot_lab = NULL,
x1_lab = "x1",
x2_lab = "x2",
z_lab = "z"
)
Arguments
grid
(`list()`)
List with the `x1` and `x2` grid.zmat
(`matrix()`)
The result of evaluation at each element of the cross product of `grid$x1` and `grid$x2`.plot_lab
(`character(1)`)
Label of the plot.x1_lab
(`character(1)`)
Label of the x1 axis.x2_lab
(`character(1)`)
Label of the x2 axis.z_lab
(`character(1)`)
Label of the z axis.
Method init_layer_contour()
Initialize the plot as 2D contour. This method is called automatically by plot() and should not be called directly.
Usage
VisualizerSurface$init_layer_contour(
opacity = NULL,
colorscale = NULL,
show_title = TRUE,
...
)
Arguments
opacity
(`numeric(1)`)
Opacity of the contour plot (0-1). If NULL, uses theme default.colorscale
(`list`)
Color scale for the contour plot. If NULL or "auto", uses theme palette.show_title
(`logical(1)`)
Whether to show the plot title. Default is TRUE....
(`any`)
Further arguments passed to `add_trace(...)`....
(`any`)
Further arguments passed to `add_trace(...)`.
Method init_layer_surface()
Initialize the plot as 3D surface. This method is called automatically by plot() and should not be called directly.
Usage
VisualizerSurface$init_layer_surface(
opacity = NULL,
colorscale = NULL,
show_title = TRUE,
...
)
Arguments
opacity
(`numeric(1)`)
Opacity of the surface plot (0-1). If NULL, uses theme default.colorscale
(`list`)
Color scale for the surface plot. If NULL or "auto", uses theme palette.show_title
(`logical(1)`)
Whether to show the plot title. Default is TRUE....
(`any`)
Further arguments passed to `add_trace(...)`....
(`any`)
Further arguments passed to `add_trace(...)`.
Method set_layout()
Set the layout of the plotly plot. This method is used internally by plot(layout = ...) and should not be called directly.
Method set_scene()
Set the view for a 3D plot. This method is used internally by plot(scene = ...) and should not be called directly.
Method add_contours()
Add contours to the surface plot.
Arguments
contours
(`list()` or `NULL`)
Custom contour configuration. If `NULL` (default), adds default z-projected contours. Can specify x, y, and z contours with custom properties like start, end, size, and color. See plotly documentation for detailed contour options....
Additional arguments passed to the contour trace.
Method plot()
Create and return the plotly plot with model-specific layers.
Arguments
flatten
(`logical(1)`)
If TRUE, display as 2D contour plot. If FALSE, display as 3D surface plot.layout
(`list()`)
Layout options passed to `plotly::layout()`. Ignored by other visualizer types. Default is NULL.scene
(`list()`)
Scene options for 3D plots. Ignored by other visualizer types. Default is NULL....
Additional arguments passed to the parent plot method.