|
| 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) |
| |
Utility script for plotting with matplotlib
Matplotlib based plotting utilities
File edited from: https://github.com/AtsushiSakai/PythonRobotics/blob/master/utils/plot.py
| 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.])
| 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.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.