bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
plot Namespace Reference

Classes

class  Arrow3D
 

Functions

None plot_rewards (Path filename)
 
 running_mean (x, N=50)
 
None plot_vals (Path filename, str title, N=100)
 
 plot_values (v)
 
 main (filename)
 
None plot_state_values (v, str title)
 
 main (v_func_filename, avg_score_filename)
 
 rot_mat_2d (angle)
 
 angle_mod (x, zero_2_2pi=False, degree=False)
 
 plot_covariance_ellipse (x, y, cov, chi2=3.0, color="-r", ax=None)
 
 plot_ellipse (x, y, a, b, angle, color="-r", ax=None, **kwargs)
 
 plot_arrow (x, y, yaw, arrow_length=1.0, origin_point_plot_style="xr", head_width=0.1, fc="r", ec="k", **kwargs)
 
 plot_curvature (x_list, y_list, heading_list, curvature, k=0.01, c="-c", label="Curvature")
 
 _arrow3D (ax, x, y, z, dx, dy, dz, *args, **kwargs)
 
 plot_3d_vector_arrow (ax, p1, p2)
 
 plot_triangle (p1, p2, p3, ax)
 
 set_equal_3d_axis (ax, x_lims, y_lims, z_lims)
 
 plot_values (time_vec, values)
 

Variables

 N
 

Detailed Description

Utility script for plotting with matplotlib
Matplotlib based plotting utilities
File edited from: https://github.com/AtsushiSakai/PythonRobotics/blob/master/utils/plot.py

Function Documentation

◆ _arrow3D()

plot._arrow3D (   ax,
  x,
  y,
  z,
  dx,
  dy,
  dz,
args,
**  kwargs 
)
protected
Add an 3d arrow to an `Axes3D` instance.

◆ angle_mod()

plot.angle_mod (   x,
  zero_2_2pi = False,
  degree = False 
)
Angle modulo operation
Default angle modulo range is [-pi, pi)

Parameters
----------
x : float or array_like
    A angle or an array of angles. This array is flattened for
    the calculation. When an angle is provided, a float angle is returned.
zero_2_2pi : bool, optional
    Change angle modulo range to [0, 2pi)
    Default is False.
degree : bool, optional
    If True, then the given angles are assumed to be in degrees.
    Default is False.

Returns
-------
ret : float or ndarray
    an angle or an array of modulated angle.

Examples
--------
>>> angle_mod(-4.0)
2.28318531

>>> angle_mod([-4.0])
np.array(2.28318531)

>>> angle_mod([-150.0, 190.0, 350], degree=True)
array([-150., -170.,  -10.])

>>> angle_mod(-60.0, zero_2_2pi=True, degree=True)
array([300.])

◆ main() [1/2]

plot.main (   filename)

◆ main() [2/2]

plot.main (   v_func_filename,
  avg_score_filename 
)

◆ plot_3d_vector_arrow()

plot.plot_3d_vector_arrow (   ax,
  p1,
  p2 
)

◆ plot_arrow()

plot.plot_arrow (   x,
  y,
  yaw,
  arrow_length = 1.0,
  origin_point_plot_style = "xr",
  head_width = 0.1,
  fc = "r",
  ec = "k",
**  kwargs 
)
Plot an arrow or arrows based on 2D state (x, y, yaw)

All optional settings of matplotlib.pyplot.arrow can be used.
- matplotlib.pyplot.arrow:
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.arrow.html

Parameters
----------
x : a float or array_like
    a value or a list of arrow origin x position.
y : a float or array_like
    a value or a list of arrow origin y position.
yaw : a float or array_like
    a value or a list of arrow yaw angle (orientation).
arrow_length : a float (optional)
    arrow length. default is 1.0
origin_point_plot_style : str (optional)
    origin point plot style. If None, not plotting.
head_width : a float (optional)
    arrow head width. default is 0.1
fc : string (optional)
    face color
ec : string (optional)
    edge color

◆ plot_covariance_ellipse()

plot.plot_covariance_ellipse (   x,
  y,
  cov,
  chi2 = 3.0,
  color = "-r",
  ax = None 
)
This function plots an ellipse that represents a covariance matrix. The ellipse is centered at (x, y) and its shape, size and rotation are determined by the covariance matrix.

Parameters:
x : (float) The x-coordinate of the center of the ellipse.
y : (float) The y-coordinate of the center of the ellipse.
cov : (numpy.ndarray) A 2x2 covariance matrix that determines the shape, size, and rotation of the ellipse.
chi2 : (float, optional) A scalar value that scales the ellipse size. This value is typically set based on chi-squared distribution quantiles to achieve certain confidence levels (e.g., 3.0 corresponds to ~95% confidence for a 2D Gaussian). Defaults to 3.0.
color : (str, optional) The color and line style of the ellipse plot, following matplotlib conventions. Defaults to "-r" (a red solid line).
ax : (matplotlib.axes.Axes, optional) The Axes object to draw the ellipse on. If None (default), a new figure and axes are created.

Returns:
None. This function plots the covariance ellipse on the specified axes.

◆ plot_curvature()

plot.plot_curvature (   x_list,
  y_list,
  heading_list,
  curvature,
  k = 0.01,
  c = "-c",
  label = "Curvature" 
)
Plot curvature on 2D path. This plot is a line from the original path,
the lateral distance from the original path shows curvature magnitude.
Left turning shows right side plot, right turning shows left side plot.
For straight path, the curvature plot will be on the path, because
curvature is 0 on the straight path.

Parameters
----------
x_list : array_like
    x position list of the path
y_list : array_like
    y position list of the path
heading_list : array_like
    heading list of the path
curvature : array_like
    curvature list of the path
k : float
    curvature scale factor to calculate distance from the original path
c : string
    color of the plot
label : string
    label of the plot

◆ plot_ellipse()

plot.plot_ellipse (   x,
  y,
  a,
  b,
  angle,
  color = "-r",
  ax = None,
**  kwargs 
)
This function plots an ellipse based on the given parameters.

Parameters
----------
x : (float) The x-coordinate of the center of the ellipse.
y : (float) The y-coordinate of the center of the ellipse.
a : (float) The length of the semi-major axis of the ellipse.
b : (float) The length of the semi-minor axis of the ellipse.
angle : (float) The rotation angle of the ellipse, in radians.
color : (str, optional) The color and line style of the ellipse plot, following matplotlib conventions. Defaults to "-r" (a red solid line).
ax : (matplotlib.axes.Axes, optional) The Axes object to draw the ellipse on. If None (default), a new figure and axes are created.
**kwargs: Additional keyword arguments to pass to plt.plot or ax.plot.

Returns
---------
None. This function plots the ellipse based on the specified parameters.

◆ plot_rewards()

None plot.plot_rewards ( Path  filename)

◆ plot_state_values()

None plot.plot_state_values (   v,
str  title 
)

◆ plot_triangle()

plot.plot_triangle (   p1,
  p2,
  p3,
  ax 
)

◆ plot_vals()

None plot.plot_vals ( Path  filename,
str  title,
  N = 100 
)

◆ plot_values() [1/2]

plot.plot_values (   time_vec,
  values 
)

◆ plot_values() [2/2]

plot.plot_values (   v)

◆ rot_mat_2d()

plot.rot_mat_2d (   angle)
Create 2D rotation matrix from an angle

Parameters
----------
angle :

Returns
-------
A 2D rotation matrix

Examples
--------
>>> angle_mod(-4.0)

◆ running_mean()

plot.running_mean (   x,
  N = 50 
)

◆ set_equal_3d_axis()

plot.set_equal_3d_axis (   ax,
  x_lims,
  y_lims,
  z_lims 
)
Helper function to set equal axis

Args:
    ax (Axes3DSubplot): matplotlib 3D axis, created by
    `ax = fig.add_subplot(projection='3d')`
    x_lims (np.array): array containing min and max value of x
    y_lims (np.array): array containing min and max value of y
    z_lims (np.array): array containing min and max value of z

Variable Documentation

◆ N

plot.N