]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxPlotCanvas.py
Added PyPlot
[wxWidgets.git] / wxPython / demo / wxPlotCanvas.py
CommitLineData
8fa876ca
RD
1# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2#
3# o Updated for wx namespace
4#
5# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net)
6#
7# o wxPlotCanvas must be updated with new draw mechanics (tuples) before
8# it can be used with 2.5.
9#
cf694132 10
8fa876ca
RD
11import wx
12import wx.lib.wxPlotCanvas as plot
13
14import Numeric
cf694132
RD
15
16#---------------------------------------------------------------------------
17
18def _InitObjects():
19 # 100 points sin function, plotted as green circles
20 data1 = 2.*Numeric.pi*Numeric.arange(200)/200.
21 data1.shape = (100, 2)
22 data1[:,1] = Numeric.sin(data1[:,0])
8fa876ca 23 markers1 = plot.PolyMarker(data1, color='green', marker='circle',size=1)
cf694132
RD
24
25 # 50 points cos function, plotted as red line
26 data1 = 2.*Numeric.pi*Numeric.arange(100)/100.
27 data1.shape = (50,2)
28 data1[:,1] = Numeric.cos(data1[:,0])
8fa876ca 29 lines = plot.PolyLine(data1, color='red')
cf694132
RD
30
31 # A few more points...
32 pi = Numeric.pi
8fa876ca 33 markers2 = plot.PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.),
cf694132
RD
34 (3.*pi/4., -1)], color='blue',
35 fillcolor='green', marker='cross')
36
8fa876ca 37 return plot.PlotGraphics([markers1, lines, markers2])
cf694132
RD
38
39
40#---------------------------------------------------------------------------
41
42
43def runTest(frame, nb, log):
8fa876ca 44 win = plot.PlotCanvas(nb)
cf694132
RD
45 win.draw(_InitObjects(),'automatic','automatic');
46 return win
47
8fa876ca 48overview = plot.__doc__
cf694132
RD
49
50#---------------------------------------------------------------------------
1fded56b
RD
51
52
1fded56b
RD
53if __name__ == '__main__':
54 import sys,os
55 import run
56 run.main(['', os.path.basename(sys.argv[0])])