ograph package

Subpackages

Submodules

ograph.oconfig module

ograph.oconfig.axis_labels(enable: bool = False) None[source]
ograph.oconfig.axis_lines(enable: bool = True) None[source]
ograph.oconfig.large_text(enable: bool = True) None[source]

ograph.ofig module

Custom plotting library.

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 invoke pyplot.axes() to create an Axes. Return both objects in a tuple.

Parameters:
  • arg

    None or 4-tuple.

    • None: A new full window Axes is added using subplot(**kwargs).

    • 4-tuple of floats rect = (left, bottom, width, height): Add a new Axes with dimensions rect in normalized (0, 1) units, using Figure.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 invoke pyplot.axes() to create an Axes3D. Return both objects in a tuple.

Parameters:
  • arg

    None or 4-tuple.

    • None: A new full window Axes is added using subplot(**kwargs).

    • 4-tuple of floats rect = (left, bottom, width, height): Add a new Axes with dimensions rect in normalized (0, 1) units, using Figure.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()

ograph.ofunc module

ograph.ofunc.rosenbrock(*args: float) float[source]

Rosenbrock function.

Multi-dimensional test function where the global minimum is located inside a flat valley.

ograph.ofunc.himmelblau(x: float, y: float) float[source]

Himmelblau function.

2-dimensional test function with several minimum.

ograph.oplot module

exception ograph.oplot.DimensionError[source]

Bases: ValueError

Raised when the dimension of a figure does not agree with the plot.

When this happens, something is going seriously wrong.

__init__(expected: str, actual: str)[source]
Parameters:
  • expected – Dimensions of the plot

  • actual – Dimensions of the figure

ograph.oplot.ensure_axes_dimension(axes: Axes | Axes3D, dim: int) None[source]

Assert if the given axes is of the specified dimension.

Raises:

DimensionError – if dim does not agree with the dimension of axes:.

ograph.oplot.view_rotate(h_rotate: float, v_rotate: float) None[source]

Rotate the current Axes3D.

@param h_rotate the degree to rotate vertically @param v_rotate the degree to rotate horizontally

ograph.oplot.view_axis_pos(pos: str | None) None[source]

Position labels and ticks of the current Axes3D.

Parameters:

pos – The position, one of 'lower', 'upper', 'default', 'both', 'none', and None.

ograph.oplot.high_res() None[source]

Set figures to render in higher resolution.

Set runtime configuration figure.dpi to 200.

Effect:

Change runtime configurations.

ograph.oplot.low_res() None[source]

Set figures to render in the default resolution.

Set runtime configuration figure.dpi to 100, the default value.

Effect:

Change runtime configurations.

ograph.oplot.annotate(title: str, xlabel: str, ylabel: str, zlabel: str | None = None) None[source]

Annotate the current figure.

Set title, xlabel, and ylabel of 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.oplot.heatmap(data: ndarray[tuple[Any, Any], dtype[float64]] | Sequence[Sequence[float]], 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: ndarray[tuple[Any, Any], dtype[float64]] | Sequence[Sequence[float]] | ndarray[tuple[Any, Any, Any], dtype[float64]] | Sequence[Sequence[Sequence[float]]]) 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: ndarray[tuple[Any], dtype[float64]] | Sequence[float], end: ndarray[tuple[Any], dtype[float64]] | Sequence[float], *args: Any, **kwargs: Any) None[source]

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 – the number of points sampled over each axis.

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 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 – the number of points sampled over each axis.

  • 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 – the number of points sampled over each axis.

  • 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.splatter(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]
ograph.oplot.shatter(xs: ndarray[tuple[Any], dtype[float64]] | Sequence[float], ys: ndarray[tuple[Any], dtype[float64]] | Sequence[float], plot_links: bool = False, *, edge_config: dict[str, Any] = {}, node_config: dict[str, Any] = {}, fill_config: dict[str, Any] = {}) None[source]
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]

Module contents