Skip to contents

Visualizes a two-dimensional function \(f: \mathbb{R}^2 \to \mathbb{R}\).

Super class

vistool::Visualizer -> Visualizer2D

Public fields

fun_x1

(`numeric(n)`)

fun_x2

(`numeric(n)`)

fun_y

(`numeric(n)`)

title

(`character(1)`)

lab_x1

(`character(1)`)

lab_x2

(`character(1)`)

lab_y

(`character(1)`)

Methods

Inherited methods


Method new()

Creates a new instance of this [R6][R6::R6Class] class.

Usage

Visualizer2D$new(
  fun_x1,
  fun_x2,
  fun_y,
  title = NULL,
  lab_x1 = "x1",
  lab_x2 = "x2",
  lab_y = "y"
)

Arguments

fun_x1

(`numeric()`) x-values of function.

fun_x2

(`numeric()`) x-values of function.

fun_y

(`numeric()`) y-values of function.

title

(`character(1)`) Title of plot.

lab_x1

(`character(1)`) Label of x-axis.

lab_x2

(`character(1)`) Label of x-axis.

lab_y

(`character(1)`) Label of y-axis.


Method plot()

Create and return the ggplot2 plot.

Usage

Visualizer2D$plot(
  text_size = 11,
  title_size = NULL,
  theme = "minimal",
  background = "white",
  color_palette = "viridis",
  plot_title = NULL,
  plot_subtitle = NULL,
  x_lab = NULL,
  y_lab = NULL,
  x_limits = NULL,
  y_limits = NULL,
  show_grid = TRUE,
  grid_color = "gray90",
  show_legend = TRUE,
  legend_position = "right",
  legend_title = NULL,
  show_title = TRUE
)

Arguments

text_size

(`numeric(1)`)
Base text size for plot elements. Default is 11.

title_size

(`numeric(1)`)
Title text size. If NULL, defaults to text_size + 2.

theme

(`character(1)`)
ggplot2 theme to use. One of "minimal", "bw", "classic", "gray", "light", "dark", "void". Default is "minimal".

background

(`character(1)`)
Background color for the plot. Default is "white".

color_palette

(`character(1)`)
Color palette for the fill scale. One of "viridis", "plasma", "grayscale". Default is "viridis".

plot_title

(`character(1)`)
Main plot title. If NULL, uses the visualizer's default title. Default is NULL.

plot_subtitle

(`character(1)`)
Plot subtitle. If NULL, no subtitle is shown. Default is NULL.

x_lab

(`character(1)`)
X-axis label. If NULL, uses the visualizer's default label. Default is NULL.

y_lab

(`character(1)`)
Y-axis label. If NULL, uses the visualizer's default label. Default is NULL.

x_limits

(`numeric(2)`)
X-axis limits as c(min, max). If NULL, uses automatic limits. Default is NULL.

y_limits

(`numeric(2)`)
Y-axis limits as c(min, max). If NULL, uses automatic limits. Default is NULL.

show_grid

(`logical(1)`)
Whether to show axis grid lines. Default is TRUE.

grid_color

(`character(1)`)
Color of grid lines. Default is "gray90".

show_legend

(`logical(1)`)
Whether to show the legend. Default is TRUE.

legend_position

(`character(1)`)
Position of the legend. One of "top", "right", "bottom", "left", "none". Default is "right".

legend_title

(`character(1)`)
Title for the legend. If NULL, uses default based on visualizer type. Default is NULL.

show_title

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

Returns

A ggplot2 object.


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.