Graph Elements

Description

Two classes, Graph and GraphPlot, containing the values and formatting of the data to plot on graphs.

Graph

class krajjat.classes.graph_element.Graph

Class containing multiple plots (each being a classes.graph_element.GraphPlot) to display on the same graph.

New in version 2.0.

plots

A list of GraphPlot elements to display on the same graph.

Type:

list(GraphPlot)

Graph.add_plot(x, y, sd=None, line_width=1.0, color='#000000', label=None)

Creates and adds a classes.graph_element.GraphPlot element to the plots attribute.

New in version 2.0.

Parameters:
  • x (list(float) or numpy.array(float)) – An array of values to plot on the x-axis.

  • y (list(float) or numpy.array(float)) – An array of values to plot on the y-axis.

  • sd (list(float), numpy.array(float), or None, optional) – A list containing the standard deviations of x.

  • line_width (float, optional) – The width of the line to plot on the graph, in pixels. By default, the line width is 1 pixel.

  • color (str, optional) – The hexadecimal value of the color of the line, prefixed by a number sign (#). By default, the color is black.

  • label (str, optional) – The label of the series.

Graph.add_graph_plot(graph_plot)

Adds an already created classes.graph_element.GraphPlot element to the plots attribute.

New in version 2.0.

Parameters:

graph_plot (GraphPlot) – A GraphPlot element.

Graph.__repr__()

Returns a textual representation of the content of the Graph element, indicating the number of plots and their respective dimensions.

New in version 2.0.

Returns:

A string representation of the content of the Graph element, indicating the number of plots and their respective dimensions.

Return type:

str

GraphPlot

class krajjat.classes.graph_element.GraphPlot(x, y, sd=None, line_width=1.0, color='#000000', label=None)

Class containing the data of the x and y-axis to plot in a graph, along with display settings such as line width and color.

New in version 2.0.

Parameters:
  • x (list(float) or numpy.array(float)) – An array of values to plot on the x-axis.

  • y (list(float) or numpy.array(float)) – An array of values to plot on the y-axis.

  • sd (list(float), numpy.array(float), or None, optional) – A list containing the standard deviations of x.

  • line_width (float, optional) – The width of the line to plot on the graph, in pixels. By default, the line width is 1 pixel.

  • color (str, optional) – The hexadecimal value of the color of the line, prefixed by a number sign (#). By default, the color is black.

  • label (str, optional) – The label of the series.

x

The array of values to plot on the x-axis.

Type:

numpy.array(float)

y

The array of values to plot on the y-axis.

Type:

numpy.array(float)

sd

The array containing the standard deviations of x.

Type:

numpy.array(float), or None, optional

line_width

The width of the line to plot on the graph, in pixels.

Type:

float

color

The hexadecimal value of the color of the line, prefixed by a number sign (#).

Type:

str

label

The label of the series.

Type:

str, optional

GraphPlot.get_extrema(x_min=None, x_max=None)

Returns the min and the max of the y array, given the x limits.

New in version 2.0.

Parameters:
  • x_min (int|float, optional) – The minimum value of the x-axis. If None, sets the x_min to the minimum value of the x array.

  • x_max (int|float, optional) – The maximum value of the x-axis. If None, sets the x_max to the maximum value of the x array.

Returns:

The minimum and maximum values of the y array, given the x limits.

Return type:

int|float, int|float