Skip to contents

A 2D coordinate system with x and y axes. Supports tick marks, axis labels, function plotting, area shading, and coordinate mapping.

Super classes

manimR::MObject -> manimR::VMobject -> Axes

Public fields

x_range

c(min, max, step) for x-axis

y_range

c(min, max, step) for y-axis

x_length

Width in scene units

y_length

Height in scene units

x_axis

The x-axis NumberLine

y_axis

The y-axis NumberLine

include_ticks

Include tick marks

include_numbers

Include number labels

tips

Include arrow tips on axes

axis_config

Config list for both axes

Methods

Inherited methods


Method new()

Create Axes

Usage

Axes$new(
  x_range = c(-5, 5, 1),
  y_range = c(-3, 3, 1),
  x_length = 10,
  y_length = 6,
  tips = TRUE,
  include_ticks = TRUE,
  include_numbers = FALSE,
  axis_config = NULL,
  color = WHITE,
  ...
)

Arguments

x_range

c(min, max, step)

y_range

c(min, max, step)

x_length

Width in scene units

y_length

Height in scene units

tips

Include arrow tips

include_ticks

Include tick marks

include_numbers

Include number labels

axis_config

Additional axis configuration

color

Axis color

...

Additional args


Method c2p()

Coordinate to Point: map data coordinates to scene

Usage

Axes$c2p(x, y, z = 0)

Arguments

x

Data x value

y

Data y value

z

Data z value (default 0)

Returns

Scene coordinate c(x, y, z)


Method p2c()

Point to Coordinate: inverse of c2p

Usage

Axes$p2c(point)

Arguments

point

Scene coordinate

Returns

c(x_data, y_data)


Method coords_to_point()

Alias for c2p (coords_to_point)

Usage

Axes$coords_to_point(x, y, z = 0)


Method point_to_coords()

Alias for p2c (point_to_coords)

Usage

Axes$point_to_coords(point)


Method plot()

Plot a function y = f(x) as a VMobject curve

Usage

Axes$plot(
  func,
  x_range = NULL,
  color = YELLOW,
  stroke_width = DEFAULT_STROKE_WIDTH,
  num_points = 200
)

Arguments

func

Function(x) -> y

x_range

Optional c(min, max) to override axis range

color

Curve color

stroke_width

Stroke width

num_points

Number of sample points

Returns

VMobject representing the graph


Method get_graph()

Alias for plot (Manim compatibility)

Usage

Axes$get_graph(func, ...)


Method get_area()

Get the area between a graph and the x-axis

Usage

Axes$get_area(graph, x_range = NULL, color = BLUE, fill_opacity = 0.5)

Arguments

graph

A graph VMobject from plot()

x_range

c(min, max) for the shaded region

color

Fill color

fill_opacity

Fill opacity

Returns

VMobject representing the shaded area


Method plot_line_graph()

Plot a line graph from data vectors

Usage

Axes$plot_line_graph(
  x_values,
  y_values,
  color = YELLOW,
  stroke_width = DEFAULT_STROKE_WIDTH
)

Arguments

x_values

Vector of x

y_values

Vector of y

color

Line color

stroke_width

Stroke width

Returns

VMobject


Method add_axis_labels()

Add axis labels

Usage

Axes$add_axis_labels(x_label = "x", y_label = "y", font_size = 36)

Arguments

x_label

Label for x-axis

y_label

Label for y-axis

font_size

Label font size


Method get_origin()

Get the origin point in scene coordinates

Usage

Axes$get_origin()


Method clone()

The objects of this class are cloneable with this method.

Usage

Axes$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.