gui.charting.graph — Draws several types of graph

This module contains the FunctionGraph and PointGraph classes, which are responsible for drawing the graphs shown on a Chart.

To add these graphs to a Chart, use its addGraph() or addSecondaryGraph() methods.

A usage example can be found on the documentation page of the gui.charting package.

The FunctionGraph Class

class gui.charting.graph.FunctionGraph(function, color, drawOnFrame=True)

Creates a new graph that draws a continuous line using a function that accepts any float value in the displayed range as an input and returns a float value.

Sections of the graph that lie outside the range shown on the graph are not drawn. If drawOnFrame is False, values at zero and the ordinates’s maximum value will not be drawn either.

color may be a gtk.gdk.Color object, an X11 color name ('misty rose') or a hexadecimal string ('#FFE4E1').

Note

The graph draws one y value for each pixel of the chart area’s width. If the function rapidly changes its y values back and forth, that change may lie between two x values for which y values are drawn, and may thus not appear on the chart.

FunctionGraph.draw(chart, abscissa, ordinate)

Draws the graph on the given Chart. abscissa and ordinate are the Axis instances whose dimensions are used for drawing the graph.

This method should only be called by Chart.

The PointGraph Class

class gui.charting.graph.PointGraph(points, color, style='squares')

Creates a new graph that draws a series of marks representing discrete values. Marks that lie outside the ranges shown on the graph are not drawn.

color may be a gtk.gdk.Color object, an X11 color name ('misty rose') or a hexadecimal string ('#FFE4E1').

style determines the type of mark used. 'squares' and 'diamonds' are supported.

PointGraph.draw(chart, abscissa, ordinate)

Draws the graph on the given Chart. abscissa and ordinate are the Axis instances whose dimensions are used for drawing the graph.

This method should only be called by Chart.

Constants

gui.charting.graph.SQUARE_SIZE
The size of the squares the PointGraph uses to mark a point if its style is 'squares', in pixels. Should be odd.
gui.charting.graph.DIAMOND_SIZE
The size of the diamonds the PointGraph uses to mark a point if its style is 'diamonds', in pixels. Should be odd.

Table Of Contents

Previous topic

gui.charting.axis — Handles the charts’ axes

Next topic

The ops Package