コード例 #1
0
class ChartDialog(wx.Dialog):
    def __init__(self, parent, id=-1, title=""):
        self.result = title.__getitem__('result')
        self.objectivenames = title.__getitem__('objectivenames')
        self.objectivenumber = len(self.objectivenames)
        self.variablenames = title.__getitem__('variablenames')
        self.variablenumber = len(self.variablenames)
        wx.Dialog.__init__(self, parent, id, title=u'结果', size=(400, 350),
                           style=wx.DEFAULT_DIALOG_STYLE|wx.THICK_FRAME|wx.RESIZE_BORDER|wx.TAB_TRAVERSAL)
        self.xcb = wx.ComboBox(self, choices=self.objectivenames, style=wx.CB_READONLY)
        self.ycb = wx.ComboBox(self, choices=self.objectivenames, style=wx.CB_READONLY)
        drawButton = wx.Button(self, label=u'确定', id=wx.ID_ANY)
        quitButton = wx.Button(self, label=u'退出', id=wx.ID_CANCEL)
        xlabel = wx.StaticText(self, label=u'横坐标(x):')
        ylabel = wx.StaticText(self, label=u'纵坐标(y):')
        xBoxSizer = wx.BoxSizer(wx.HORIZONTAL)
        yBoxSizer = wx.BoxSizer(wx.HORIZONTAL)
        buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
        xBoxSizer.Add(xlabel, 0, wx.ALL, 8)
        xBoxSizer.Add(self.xcb, 0, wx.ALL, 8)
        yBoxSizer.Add(ylabel, 0, wx.ALL, 8)
        yBoxSizer.Add(self.ycb, 0, wx.ALL, 8)
        buttonSizer.Add(drawButton, 0, wx.ALL, 8)
        buttonSizer.Add(quitButton, 0, wx.ALL, 8)
        MainSizer = wx.BoxSizer(wx.VERTICAL)
        MainSizer.Add(xBoxSizer, 0, wx.ALL, 8)
        MainSizer.Add(yBoxSizer, 0, wx.ALL, 8)
        MainSizer.Add(buttonSizer, 0,wx.ALL, 8)
        self.SetSizer(MainSizer)

        self.Bind(wx.EVT_BUTTON, self.drawAPP, drawButton)

    def drawAPP(self, e):
        self.app = PlotApp()
        try:
            xlabel = self.xcb.GetValue()
            xindex = self.objectivenames.index(xlabel)
            ylabel = self.ycb.GetValue()
            yindex = self.objectivenames.index(ylabel)
        except:
            wx.MessageBox(u'请先选择x,y数据', u'提示', wx.OK | wx.ICON_INFORMATION)
        x = []
        y = []
        for individual in self.result:
            x.append(individual[xindex])
            y.append(individual[yindex])

        self.app.plot(x, y, title=xlabel+' - '+ylabel, label=xlabel+' - '+ylabel, xlabel=xlabel, ylabel=ylabel)
        self.app.run()
コード例 #2
0
    def plot_graph(self, data):

        x = [i for i in range(0, len(data))]

        x_data = np.array(x)
        y_data = np.array(data)

        app = PlotApp()

        app.plot(x_data,
                 y_data,
                 title='Compound interest over term',
                 label='Compound interest',
                 ylabel='Funds (£)',
                 xlabel='Time (Months)')

        app.write_message('Try Help->Quick Reference')
        app.run()
コード例 #3
0
    def drawAPP(self, e):
        self.app = PlotApp()
        try:
            xlabel = self.xcb.GetValue()
            xindex = self.objectivenames.index(xlabel)
            ylabel = self.ycb.GetValue()
            yindex = self.objectivenames.index(ylabel)
        except:
            wx.MessageBox(u'请先选择x,y数据', u'提示', wx.OK | wx.ICON_INFORMATION)
        x = []
        y = []
        for individual in self.result:
            x.append(individual[xindex])
            y.append(individual[yindex])

        self.app.plot(x, y, title=xlabel+' - '+ylabel, label=xlabel+' - '+ylabel, xlabel=xlabel, ylabel=ylabel)
        self.app.run()
コード例 #4
0
from ABKSectionPoint import *
from DrawSection import DrawGeometry
from wxmplot import PlotApp

if __name__ == "__main__":
    Tsec = NshapeSection(30,12,20,80,5,5,5)
    geo = GeoCalculator(Tsec)
    geo.Solve()
    print geo.Area()
    p = geo.Centroid()
    alfa = geo.tan_alfa()
    print p
    print "a=" + str(alfa)

    app = PlotApp()
    Path = DrawGeometry(Tsec)
    Path.Draw()

    #newIsec = Isec.moveCoor(-p[0], -p[1])
    #origin = Point(0,0)

    #newIsec = Isec.rotate(pi/4, p)
    #newIsec = Isec.transform(-p[0],-p[1],-alfa, origin)

    #geo1 = GeoCalculator(newIsec)
    #geo1.Solve()
    #print geo1.Area()
    #print geo1.Centroid()

    for i in Path._paths:
        m,n=zip(*i)
コード例 #5
0
#!/usr/bin/python

from wxmplot import PlotApp
from datetime import datetime
f = open('time.dat', 'r')
l = f.readlines()
f.close()
t = []
x = []
for i in l:
    j = i[:-1].strip().split()
    t.append(datetime.fromtimestamp(float(j[0])))
    x.append(float(j[1]))

app = PlotApp()
app.plot(t, x, use_dates=True, drawstyle='steps-post', marker='+')
app.set_title('Time series data:')
app.run()
コード例 #6
0
ファイル: test.py プロジェクト: zhaojicong/SchemeDesign
#!/usr/bin/env python
# simple wxmplot example

from numpy import linspace, sin, cos, random
from wxmplot import PlotApp

app = PlotApp()

x = linspace(0.0, 10.0, 101)
y = 5*sin(4*x)/(x+6)
z = cos(0.7*(x+0.3)) + random.normal(size=len(x), scale=0.2)

app.plot(x, y, title='WXMPlot Demo', label='decaying sine',
         ylabel=r'$\chi(x)$', xlabel='$x \ (\AA)$')
app.oplot(x, z, label='noisy cosine', marker='+')

app.write_message('Try Help->Quick Reference')
app.run()
コード例 #7
0
#!/usr/bin/python
#

from wxmplot import PlotApp
import numpy as np

npts = 41
x = np.linspace(0, 10.0, npts)
y = 0.4 * np.cos(x / 2.0) + np.random.normal(scale=0.03, size=npts)
dy = 0.03 * np.ones(npts) + 0.01 * np.sqrt(x)

app = PlotApp()
app.plot(x,
         y,
         dy=dy,
         color='red',
         linewidth=0,
         marker='o',
         xlabel='x',
         ylabel='y',
         title='Plot with error bars')
app.run()
コード例 #8
0
ファイル: basic_screenshot.py プロジェクト: newville/wxmplot
#!/usr/bin/env python
# simple wxmplot example

from numpy import linspace, sin, cos, random
from wxmplot import PlotApp

app = PlotApp()

random.seed(1)

x = linspace(0.0, 15.0, 151)
y = 5*sin(4*x)/(x*x+6)
z = cos(0.7*(x+0.3)) + random.normal(size=len(x), scale=0.11)

app.plot(x, y, title='WXMPlot example',
         label='decaying sine',
         ylabel=r'$\phi(x)$',
         xlabel=r'$x \> \rm (\AA)$')
app.oplot(x, z, label='noisy cosine', marker='+', show_legend=True)

app.write_message('Try Help->Quick Reference')
app.run()
コード例 #9
0
ファイル: errorbar.py プロジェクト: astyl/wxmplot
#!/usr/bin/python
#

from wxmplot import PlotApp
import numpy as np

npts = 41
x  = np.linspace(0, 10.0, npts)
y  = 0.4 * np.cos(x/2.0) + np.random.normal(scale=0.03, size=npts)
dy = 0.03 * np.ones(npts) + 0.01 * np.sqrt(x)

app = PlotApp()
app.plot(x, y, dy=dy, color='red', linewidth=0, marker='o',
         xlabel='x', ylabel='y', title='Plot with error bars')
app.run()
コード例 #10
0
ファイル: basic_screenshot.py プロジェクト: tula32/wxmplot
#!/usr/bin/env python
# simple wxmplot example

from numpy import linspace, sin, cos, random
from wxmplot import PlotApp

app = PlotApp()

random.seed(1)

x = linspace(0.0, 15.0, 151)
y = 5 * sin(4 * x) / (x * x + 6)
z = cos(0.7 * (x + 0.3)) + random.normal(size=len(x), scale=0.11)

app.plot(x,
         y,
         title='WXMPlot example',
         label='decaying sine',
         ylabel=r'$\phi(x)$',
         xlabel=r'$x \> \rm (\AA)$')
app.oplot(x, z, label='noisy cosine', marker='+', show_legend=True)

app.write_message('Try Help->Quick Reference')
app.run()
コード例 #11
0
#!/usr/bin/python
#
#  compare, for reference:
#   http://www.mps.mpg.de/dislin/exa_curv.html
#   http://www.mps.mpg.de/dislin/exa_python.html#section_1

from wxmplot import PlotApp
import numpy as np

x  = 3.6*np.arange(101)
y1 = np.cos(np.pi*x/180)
y2 = np.sin(np.pi*x/180)

app = PlotApp()
app.plot(x, y1, color='red',
         xlabel='x', ylabel='y',
         title='DISLIN Comparison\nsin(x) and cos(x)',
         xmin=0, xmax=360.0)
app.oplot(x, y2, color='green3', marker='+')


app.run()
コード例 #12
0
ファイル: plot_fromdatafile.py プロジェクト: astyl/wxmplot
#!/usr/bin/python

from wxmplot import PlotApp

f = open('xafs.dat','r')
x = []
y = []
titles = []
for i in f.readlines():
    i =  i[:-1].strip()
    if i.startswith('#'):
        titles.append(i)
    else:
        j = i.split()
        x.append(float(j[0]))
        y.append(float(j[1]))
f.close()
app = PlotApp()
app.plot(x,y,xlabel='E (eV)', label='As K', marker='+',linewidth=1)
app.set_title('Test Plot')
app.write_message('MPlot PlotFrame example: Try Help->Quick Reference')
app.run()
コード例 #13
0
from wxmplot import PlotApp
from numpy import arange, sin, cos, exp, pi

xx  = arange(0.0,12.0,0.1)
y1  = 1*sin(2*pi*xx/3.0)
y2  = 4*cos(2*pi*(xx-1)/5.0)/(6+xx)
y3  = -pi + 2*(xx/10. + exp(-(xx-3)/5.0))

p = PlotApp()
p.plot(xx, y1, color='blue',  style='dashed',
       title='Example PlotApp',  label='a',
       ylabel=r'$k^2\chi(k) $',
       xlabel=r'$  k \ (\AA^{-1}) $' )

p.oplot(xx, y2,  marker='+', linewidth=0, label =r'$ x_1 $')
p.oplot(xx, y3,  style='solid',          label ='x_2')
p.write_message('Try Help->Quick Reference')
p.run()
コード例 #14
0
#!/usr/bin/python

from wxmplot import PlotApp

f = open('xafs.dat', 'r')
x = []
y = []
titles = []
for i in f.readlines():
    i = i[:-1].strip()
    if i.startswith('#'):
        titles.append(i)
    else:
        j = i.split()
        x.append(float(j[0]))
        y.append(float(j[1]))
f.close()
app = PlotApp()
app.plot(x, y, xlabel='E (eV)', label='As K', marker='+', linewidth=1)
app.set_title('Test Plot')
app.write_message('MPlot PlotFrame example: Try Help->Quick Reference')
app.run()