Skip to contents

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

Super class

vistool::Visualizer -> Visualizer1D

Public fields

fun_x

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

fun_y

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

title

(`character(1)`)
Title of plot

lab_x

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

lab_y

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

line_col

(`character(1)`)
Color of plotted line

line_width

(`numeric(1)`)
Width of plotted line

line_type

(`character(1)`)
Type of plotted line

points_col

(`character(1)`)
Color of plotted points

points_size

(`numeric(1)`)
Size of plotted points

points_shape

(`integer(1)`)
Shape of plotted points

points_alpha

(`numeric(1)`)
Alpha blending of plotted points

Methods

Inherited methods


Method new()

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

Usage

Visualizer1D$new(fun_x, fun_y, title = NULL, lab_x = "x", lab_y = "y")

Arguments

fun_x

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

fun_y

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

title

(`character(1)`)
Title of plot

lab_x

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

lab_y

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


Method plot()

Create and return the ggplot2 plot.

Usage

Visualizer1D$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)`)
Default color palette to use. 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

Visualizer1D$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.