Skip to content

Graphing

A module for making and displaying graphs on the screen, created for use with the Window API.

Usage

Currently supported graph types:

  • Line Graphs
  • Bar Graphs
  • Scatter Plots
  • Pie Charts
  • Histograms
  • Box Plot
  • Area Graph

Graph Options

The GraphOptions class is used to specify the options for a graph. To create a GraphOptions object, use the following code:

from tailwindall.graphing import GraphOptions
from tailwindall.util import ImageScale
opts = GraphOptions("X Label", "Y Label", "Title", ImageScale(1, 1))

Arguments

ArgumentTypeDescriptionDefaultSee Also
x_labelstrThe label for the x axisNo Default
y_labelstrThe label for the y axisNo Default
titlestrThe title of the graphNo Default
imageImageScaleThe size of the graphNo DefaultImageScale

Line Graphs

To create a line graph, use the following code:

from tailwindall.graphing import LineGraph, GraphOptions
from tailwindall.window import Window
from tailwindall.util import ImageScale, WindowProperties, PlaceData, CenterAnchor
win = Window(None, "Line Graph", WindowProperties())
opts = GraphOptions("X Label", "Y Label", "Title", ImageScale(1, 1))
linegraph = LineGraph([], [], opts, win)
win.add_widget(linegraph.display(), PlaceData(0, 0, CenterAnchor.get_anchor()))
win.main_loop()

Arguments

ArgumentTypeDescriptionDefaultSee Also
x_dataList[float]The x data to be graphedNo Default
y_dataList[float]The y data to be graphedNo Default
optionsGraphOptionsThe options for the graphNo DefaultGraphOptions
windowWindowThe window to display the graph onNo DefaultWindow

Bar Graphs

To create a bar graph, use the following code:

from tailwindall.graphing import BarGraph, GraphOptions
from tailwindall.window import Window
from tailwindall.util import ImageScale, WindowProperties, PlaceData, CenterAnchor
win = Window(None, "Bar Graph", WindowProperties())
opts = GraphOptions("X Label", "Y Label", "Title", ImageScale(1, 1))
bargraph = BarGraph([], [], opts, win)
win.add_widget(bargraph.display(), PlaceData(0, 0, CenterAnchor.get_anchor()))
win.main_loop()

Arguments

ArgumentTypeDescriptionDefaultSee Also
x_dataList[float]The x data to be graphedNo Default
y_dataList[float]The y data to be graphedNo Default
optionsGraphOptionsThe options for the graphNo DefaultGraphOptions
windowWindowThe window to display the graph onNo DefaultWindow

Scatter Plots

To create a scatter plot, use the following code:

from tailwindall.graphing import ScatterPlot, GraphOptions
from tailwindall.window import Window
from tailwindall.util import ImageScale, WindowProperties, PlaceData, CenterAnchor
win = Window(None, "Scatter Plot", WindowProperties())
opts = GraphOptions("X Label", "Y Label", "Title", ImageScale(1, 1))
scatterplot = ScatterPlot([], [], opts, win)
win.add_widget(scatterplot.display(), PlaceData(0, 0, CenterAnchor.get_anchor()))
win.main_loop()

Arguments

ArgumentTypeDescriptionDefaultSee Also
x_dataList[float]The x data to be graphedNo Default
y_dataList[float]The y data to be graphedNo Default
optionsGraphOptionsThe options for the graphNo DefaultGraphOptions
windowWindowThe window to display the graph onNo DefaultWindow

Pie Charts

To create a pie chart, use the following code:

from tailwindall.graphing import PieGraph, GraphOptions
from tailwindall.window import Window
from tailwindall.util import ImageScale, WindowProperties, PlaceData, CenterAnchor
win = Window(None, "Pie Chart", WindowProperties())
opts = GraphOptions("X Label", "Y Label", "Title", ImageScale(1, 1))
piechart = PieGraph([], [], opts, win)
win.add_widget(piechart.display(), PlaceData(0, 0, CenterAnchor.get_anchor()))
win.main_loop()

Arguments

ArgumentTypeDescriptionDefaultSee Also
x_dataList[float]The x data to be graphedNo Default
y_dataList[float]The y data to be graphedNo Default
optionsGraphOptionsThe options for the graphNo DefaultGraphOptions
windowWindowThe window to display the graph onNo DefaultWindow

Histograms

To create a histogram, use the following code:

from tailwindall.graphing import HistogramGraph, GraphOptions
from tailwindall.window import Window
from tailwindall.util import ImageScale, WindowProperties, PlaceData, CenterAnchor
win = Window(None, "Histogram", WindowProperties())
opts = GraphOptions("X Label", "Y Label", "Title", ImageScale(1, 1))
histogram = HistogramGraph([], [], opts, win)
win.add_widget(histogram.display(), PlaceData(0, 0, CenterAnchor.get_anchor()))
win.main_loop()

Arguments

ArgumentTypeDescriptionDefaultSee Also
x_dataList[float]The x data to be graphedNo Default
y_dataList[float]The y data to be graphedNo Default
optionsGraphOptionsThe options for the graphNo DefaultGraphOptions
windowWindowThe window to display the graph onNo DefaultWindow

Box Plots

To create a box plot, use the following code:

from tailwindall.graphing import BoxPlotGraph, GraphOptions
from tailwindall.window import Window
from tailwindall.util import ImageScale, WindowProperties, PlaceData, CenterAnchor
win = Window(None, "Box Plot", WindowProperties())
opts = GraphOptions("X Label", "Y Label", "Title", ImageScale(1, 1))
boxplot = BoxPlotGraph([], [], opts, win)
win.add_widget(boxplot.display(), PlaceData(0, 0, CenterAnchor.get_anchor()))
win.main_loop()

Arguments

ArgumentTypeDescriptionDefaultSee Also
x_dataList[float]The x data to be graphedNo Default
y_dataList[float]The y data to be graphedNo Default
optionsGraphOptionsThe options for the graphNo DefaultGraphOptions
windowWindowThe window to display the graph onNo DefaultWindow

Area Graphs

To create an area graph, use the following code:

from tailwindall.graphing import AreaGraph, GraphOptions
from tailwindall.window import Window
from tailwindall.util import ImageScale, WindowProperties, PlaceData, CenterAnchor
win = Window(None, "Area Graph", WindowProperties())
opts = GraphOptions("X Label", "Y Label", "Title", ImageScale(1, 1))
areagraph = AreaGraph([], [], opts, win)
win.add_widget(areagraph.display(), PlaceData(0, 0, CenterAnchor.get_anchor()))
win.main_loop()

Arguments

ArgumentTypeDescriptionDefaultSee Also
x_dataList[float]The x data to be graphedNo Default
y_dataList[float]The y data to be graphedNo Default
optionsGraphOptionsThe options for the graphNo DefaultGraphOptions
windowWindowThe window to display the graph onNo DefaultWindow