Skip to contents

This class is used to create 2D visualizations.

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

Visualizer2D$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 with contour lines.

Usage

Visualizer2D$init_layer_contour(
  opacity = 0.8,
  colorscale = list(c(0, 1), c("rgb(176,196,222)", "rgb(160,82,45)")),
  show_title = TRUE,
  ...
)

Arguments

opacity

(`numeric(1)`)
Opacity of the layer.

colorscale

(`list()`)
The coloring of the contour.

show_title

(`logical(1)`)
Indicator whether to show the title of the plot.

...

(`any`)
Further arguments passed to `add_trace(...)`.


Method init_layer_surface()

Initialize the plot as 3D surface.

Usage

Visualizer2D$init_layer_surface(
  opacity = 0.8,
  colorscale = list(c(0, 1), c("rgb(176,196,222)", "rgb(160,82,45)")),
  show_contours = FALSE,
  show_title = TRUE,
  ...
)

Arguments

opacity

(`numeric(1)`)
Opacity of the layer.

colorscale

(`list()`)
The coloring of the surface.

show_contours

(`logical(1)`)
Indicator whether to show the contours of the surface.

show_title

(`logical(1)`)
Indicator whether to show the title of the plot.

...

(`any`)
Further arguments passed to `add_trace(...)`.


Method set_layout()

Set the layout of the plotly plot.

Usage

Visualizer2D$set_layout(...)

Arguments

...

Layout options directly passed to `layout(...)`.


Method set_scene()

Set the view for a 3D plot.

Usage

Visualizer2D$set_scene(x, y, z)

Arguments

x

(`numeric(1)`) The view from which the "camera looks down" to the plot.

y

(`numeric(1)`) The view from which the "camera looks down" to the plot.

z

(`numeric(1)`) The view from which the "camera looks down" to the plot.


Method plot()

Return the plot and hence plot it or do further processing.

Usage

Visualizer2D$plot()


Method save()

Save the plot by using plotlys `save_image()` function.

Usage

Visualizer2D$save(...)

Arguments

...

Further arguments passed to `save_image()`.


Method clone()

The objects of this class are cloneable with this method.

Usage

Visualizer2D$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.