ograph package
Subpackages
Submodules
ograph.oconfig module
Utilities that configure the current plot or all plots in the current session.
- ograph.oconfig.set_font_size(size: int) None[source]
Set the font size to
size.- Effect:
Configure the current plot.
- ograph.oconfig.use_high_res() None[source]
Set figures to render in higher resolution.
Set runtime configuration
figure.dpito 200.- Effect:
Configure all plots in the current session.
- ograph.oconfig.use_low_res() None[source]
Set figures to render in the default resolution.
Set runtime configuration
figure.dpito 100, the default value.- Effect:
Configure all plots in the current session.
ograph.ofig module
Utilities that create and check figures of different dimensions.
- ograph.ofig.fig2(xlims: Tuple[float, float] | None = None, ylims: Tuple[float, float] | None = None, arg: None | tuple[float, float, float, float] = None, **kwargs: Any) Tuple[Figure, Axes][source]
Create then return a figure with a 2-dimensional axis.
Invoke
pyplot.figure()to create figure, then invokepyplot.axes()to create anAxes. Return both objects in a tuple.- Parameters:
arg –
Noneor 4-tuple.None: A new full window Axes is added usingsubplot(**kwargs).4-tuple of floats rect =
(left, bottom, width, height): Add a new Axes with dimensions rect in normalized (0, 1) units, usingFigure.add_axes()on the current figure.
xlims – Size of figure along the X axis
ylims – Size of figure along the Y axis
*args – Positional arguments to pass to
pyplot.axes()*kwargs – Keyword arguments to pass to
pyplot.axes()
- ograph.ofig.fig3(xlims: Tuple[float, float] | None = None, ylims: Tuple[float, float] | None = None, zlims: Tuple[float, float] | None = None, arg: None | tuple[float, float, float, float] = None, **kwargs: Any) Tuple[Figure, Axes3D][source]
Create then return a figure with a 3-dimensional axis.
Invoke
pyplot.figure()to create figure, then invokepyplot.axes()to create anAxes3D. Return both objects in a tuple.- Parameters:
arg –
Noneor 4-tuple.None: A new full window Axes is added usingsubplot(**kwargs).4-tuple of floats rect =
(left, bottom, width, height): Add a new Axes with dimensions rect in normalized (0, 1) units, usingFigure.add_axes()on the current figure.
xlims – Size of figure along the X axis
ylims – Size of figure along the Y axis
ylims – Size of figure along the Y axis
*kwargs – Keyword arguments to pass to
pyplot.axes()
- exception ograph.ofig.DimensionError[source]
Bases:
ValueErrorRaised when the dimension of a figure does not agree with the plot.
When this happens, something is going seriously wrong.
- ograph.ofig.ensure_axes_dimension(axes: Axes | Axes3D, dim: int) None[source]
Assert if the given axes is of the specified dimension.
- Raises:
DimensionError – if
dimdoes not agree with the dimension ofaxes:.
- ograph.ofig.annotate(title: str, xlabel: str, ylabel: str, zlabel: str | None = None) None[source]
Annotate the current figure.
Set
title,xlabel, andylabelof the current axes. Also set runtime configurations that style annotations.To reset the parameters, call:
matplotlib.rcParams.update(matplotlib.rcParamsDefault)- Parameters:
title – Title of the figure
xlabel – Labels for the x axis
ylabel – Labels for the y axis
zlabel – Labels for the z axis
- Effect:
Plot to the current active figure. Change runtime configurations.
ograph.ofunc module
Test functions and matrices. Examples are the Himmelblau function and the unit cube.
ograph.oplot module
Utilities that plot to the current Axes.
- ograph.oplot.heatmap(data: Vec2D, xlabels: Sequence[str] | None = None, ylabels: Sequence[str] | None = None) None[source]
Plot a matrix to the current active axis as a heatmap.
- Parameters:
data – A Numpy matrix.
xlabels – labels for cells along the x axis.
ylabels – labels for cells along the x axis.
- Effects:
Plot at the current active axis.
- ograph.oplot.chull(shape: Points2D | Points3D) None[source]
Plot a convex hull to the current active axes.
Detect the shape of points by inspecting the first in the sequence.
- Parameters:
shape – A sequence of 2- or 3-dimensional points.
- Effects:
Plot at the current active axis.
- ograph.oplot.arrow(start: Point2D, end: Point2D, *args: Any, **kwargs: Any) None[source]
- ograph.oplot.arrow(start: Point3D, end: Point3D, *args: Any, **kwargs: Any) None
Plot an arrow to the current Axes or Axes3D.
- Parameters:
start – The starting point of the arrow.
end – The ending point of the arrow.
- ograph.oplot.plot(fun: Callable[[float], float], x_range: tuple[float, float], density: int = 1000, *args: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], **kwargs: Any) None[source]
Plot a contour map to the current Axes or Axes3D.
- Parameters:
fun – The function to plot.
x_range – A tuple of the beginning and end of the x axis.
density – Number of data point to plot. These points are evenly spaced over (
x_range*y_range).
- ograph.oplot.contour(fun: Callable[[float, float], float], x_range: tuple[float, float], y_range: tuple[float, float], density: int = 100, levels: int = 50, cmap: str = 'viridis', colorbar: bool = True, alpha: float = 0.5) None[source]
Plot a contour map to the current Axes3D.
- Parameters:
fun – The function to plot.
x_range – A tuple of the beginning and end of the x axis.
y_range – A tuple of the beginning and end of the y axis.
density – Number of point to plot. These points are evenly spaced over (
x_range*y_range).levels – The number of contour lines.
cmap – The colour map used by the contour map.
colorbar – If True, draw the colour bar.
- ograph.oplot.wireframe(fun: Callable[[float, float], float], x_range: tuple[float, float], y_range: tuple[float, float], density: int = 100, cmap: str = 'viridis', alpha: float = 0.9, **kwargs: dict[str, Any]) Line3DCollection[source]
Plot a wireframe map to the current Axes or Axes3D.
- Parameters:
fun – The function to plot.
x_range – A tuple of the beginning and end of the x axis.
y_range – A tuple of the beginning and end of the y axis.
density – Number of point to plot. These points are evenly spaced over
x_range.cmap – The colour map used by the contour map.
alpha – Alpha value (transparency) of the frame.
- ograph.oplot.surface(fun: Callable[[float, float], float], x_range: tuple[float, float], y_range: tuple[float, float], density: int = 100, cmap: str = 'viridis', colorbar: bool = True, alpha: float = 0.9) Line3DCollection[source]
- ograph.oplot.stems(fun: Callable[[float], float], x_range: tuple[float, float], density: int = 30, plot_links: bool = False, *, edge_args: dict[str, Any] = {}, node_args: dict[str, Any] = {}, fill_args: dict[str, Any] = {}) None[source]
PLot a stem plot to the current Axes.
- Parameters:
x_range – A tuple of the beginning and end of the x axis.
density – Number of point to plot. These points are evenly spaced over
x_range.plot_links – If
True, then plot links.
- ograph.oplot.stem(xs: Vec1D, ys: Vec1D, plot_links: bool = False, *, edge_args: dict[str, Any] = {}, node_args: dict[str, Any] = {}, fill_args: dict[str, Any] = {}) None[source]
Plot a stem plot to the current Axes. Similar to
Axes.stem(), but offers more control over style.
- ograph.oplot.shatter(xs: Vec1D, ys: Vec1D, plot_links: bool = False, *, edge_args: dict[str, Any] = {}, node_args: dict[str, Any] = {}, fill_args: dict[str, Any] = {}) None
Legacy alias for
stem().
- ograph.oplot.patch(facecolor: tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float], label: str, alpha: float = 1, width: float = 1, height: float = 0.8) None[source]
Add and label a rectangular colour patch to the current plot.
- Parameters:
label – Label to the patch.
alpha – Alpha value of the patch.
width – Width of the patch.
height – Height of the patch.