Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/plotter/plot.py
diff options
context:
space:
mode:
Diffstat (limited to 'plotter/plot.py')
-rwxr-xr-xplotter/plot.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/plotter/plot.py b/plotter/plot.py
new file mode 100755
index 0000000..36775e2
--- /dev/null
+++ b/plotter/plot.py
@@ -0,0 +1,31 @@
+"""Methods for creating plot figures."""
+
+import cairoplot
+from cairoplot.handlers.gtk import GTKHandler
+
+class CairoPlotCanvas(GTKHandler):
+ """GTK canvas displaying plots from."""
+
+ @staticmethod
+ def fromapp(app):
+ """Creates a CairoPlotCanvas from application."""
+
+ # plotsettings = plotter.settings.PlotSettings.fromapp(self)
+ xmin = app.xmin_spin.get_value()
+ xmax = app.xmax_spin.get_value()
+ xstep = (xmax - xmin) / 100.0
+
+ canvas = CairoPlotCanvas()
+
+ # get data (functions in a list)
+ functions = app.get_functions()
+
+ # create plot
+ plot = cairoplot.FunctionPlot(canvas, data=functions,
+ x_bounds=(xmin, xmax), step=xstep,
+ width=500, height=500, background="white",
+ border=20, axis=True, grid=True)
+ canvas.plot = plot
+
+ return canvas
+