Changeset 3322


Ignore:
Timestamp:
Jul 12, 2006, 8:39:02 PM (18 years ago)
Author:
steve
Message:

change to gnuplot

File:
1 edited

Legend:

Unmodified
Added
Removed
  • development/pyvolution-1d/quantity.py

    r3295 r3322  
    614614
    615615
     616def newLinePlot(title='Simple Plot'):
     617    import Gnuplot
     618    g = Gnuplot.Gnuplot()
     619    g.title(title)
     620    g('set data style linespoints')
     621    g.xlabel('x')
     622    g.ylabel('y')
     623    return g
     624
     625def linePlot(g,x,y):
     626    import Gnuplot
     627    g.plot(Gnuplot.PlotItems.Data(x.flat,y.flat))
     628
     629
     630
     631
    616632
    617633if __name__ == "__main__":
    618634    from domain import Domain
    619 
     635    from Numeric import arange
     636   
    620637    points1 = [0.0, 1.0, 2.0, 3.0]
    621638    vertex_values = [[1.0,2.0],[4.0,5.0],[-1.0,2.0]]
     
    641658    print Q1.centroid_values
    642659
    643     def fun(x):
    644         return x**2
    645 
     660    class FunClass:
     661        def __init__(self,value):
     662            self.value = value
     663
     664        def __call__(self,x):
     665            return self.value*(x**2)
     666
     667
     668    fun = FunClass(1.0)
    646669    Q1.set_values(fun,'vertices')
    647670
     
    660683    Q1.limit()
    661684
    662     from pylab import *
    663     plot(Xc,Qc)
    664 
    665     show()
     685    g1 = newLinePlot('plot 1')
     686    linePlot(g1,Xc,Qc)
    666687
    667688    points2 = arange(10)
    668 
    669 
    670689    D2 = Domain(points2)
    671690
     
    674693    Xc = Q2.domain.vertices
    675694    Qc = Q2.vertex_values
    676     plot(Xc,Qc)
    677 
    678     show()
     695
     696    g2 = newLinePlot('plot 2')
     697    linePlot(g2,Xc,Qc)
     698
     699
     700   
    679701    Q2.extrapolate_second_order()
    680702    Q2.limit()
     
    685707    print Qc
    686708
    687     plot(Xc,Qc)
    688 
    689     show()
    690 
    691 
    692 
    693 
    694 
    695 
    696 
    697 
     709    g3 = newLinePlot('plot 3')
     710    linePlot(g3,Xc,Qc)
     711    raw_input('press return')
     712
     713
     714    for i in range(10):
     715        fun = FunClass(i/10.0)
     716        Q2.set_values(fun,'vertices')
     717        Qc = Q2.vertex_values
     718        linePlot(g3,Xc,Qc)
     719
     720    raw_input('press return')
     721
     722
     723
     724
     725
     726
     727
Note: See TracChangeset for help on using the changeset viewer.