Rappture.Plot constructors/destructors Rappture.Plot([lib]) Rappture.Plot(o) methods p.name([val]) p.path([val]) p.label([val]) p.desc([val]) p.hints([val]) p.color([val]) p.property(key[, val]) p.propremove(key) p.add(x, y, fmt, name) p.add(c, name) p.count() p.curve(name) p.getNthCurve(n) p.vvalue([...]) p.random() p.diff(o) p.configure(as, c) p.dump(as, c) p.outcome() p.is() --------------------------------------- Rappture.Plot([lib]) Purpose: construct a plot object Input Arguments: at most 1 1. lib - Rappture library to associate this plot with Return Value: a newly created, empty plot object Notes: None Code Example: {{{ lib = Rappture.Library() p = Rappture.Plot(lib) }}} Rappture.Plot(o) Purpose: construct a plot object based on plot object o Input Arguments: 1 1. o - plot object to copy Return Value: a newly created plot object Notes: None Code Example: {{{ lib = Rappture.Library() p1 = Rappture.Plot(lib) p2 = Rappture.Plot(p1) }}} p.name([val]) Purpose: get/set the id name of the object Input Arguments: at most 1 1. val - new id name Return Value: the name of the object Notes: if no name is set, None will be returned the id name is used to identify this object from all other objects and should be unique val, if provided, is used to set the object name Code Example: {{{ p = Rappture.Plot() p.name() # "" p.name("fdfactor") p.name() # "fdfactor" }}} p.path([val]) Purpose: get/set the path of the object Input Arguments: at most 1 1. val - new path Return Value: path of the object Notes: if no path is set, None will be returned the path tells where this object sits in the hierarchy of objects. val, if provided, is used to set the object path Code Example: {{{ p = Rappture.Plot() p.path() # "" p.path("output") p.path() # "output" }}} p.label([val]) Purpose: get/set the label of the object Input Arguments: at most 1 1. val - new label Return Value: label of the object Notes: if no label is set, None will be returned the label is used by the graphical user interface. val, if provided, is used to set the object label Code Example: {{{ p = Rappture.Plot() p.label() # "" p.label("Fermi-Dirac Factor") p.label() # "Fermi-Dirac Factor" }}} p.desc([val]) Purpose: get/set the description of the object Input Arguments: at most 1 1. val - new description Return Value: description of the object Notes: if no description is set, None will be returned the description is used by the graphical user interface to describe what type of data is being requested and how the input is used. val, if provided, is used to set the object description Code Example: {{{ p = Rappture.Plot() p.desc() # "" p.desc("A plot of the Fermi-Dirac Factor") p.desc() # "A plot of the Fermi-Dirac Factor" }}} p.hints([val]) Purpose: get/set the hints of the object Input Arguments: at most 1 1. val - new hints Return Value: hints of the object Notes: if no hints are set, None will be returned the hints are used by the graphical user interface val, if provided, is used to set the object hints Code Example: {{{ p = Rappture.Plot() p.hints() # "" p.hints("no hints") p.hint() # "no hints" }}} p.color([val]) Purpose: get/set the color of the object Input Arguments: at most 1 1. val - new color Return Value: color of the object Notes: if no color is set, None will be returned the color is used by the graphical user interface val, if provided, is used to set the object color Code Example: {{{ p = Rappture.Plot() p.color() # "" p.color("no color") p.color() # "no color" }}} p.property(key[, val]) Purpose: get/set a generic property in the property database Input Arguments: at most 2 1. key - property name 2. val - property value Return Value: value of the property Notes: A copy val is stored in the property database Code Example: {{{ p = Rappture.Plot() p.property("name") # "" p.property("name","fdfactor") # "fdfactor" p.name() # "fdfactor" }}} p.propremove(key) Purpose: remove a property from the property database Input Arguments: 1 1. key - property name Return Value: value of the property Notes: None Code Example: {{{ p = Rappture.Plot() p.name("fdfactor") p.property("name") # "fdfactor" p.propremove("name") # "fdfactor" p.property("name") # "" }}} p.add(x, y, fmt, name) Purpose: add data for an xy curve to the plot Input Arguments: 4 1. x - list/array representing the x axis 2. y - list/array representing the y axis 3. fmt - string format of the line 4. name - string id of the newly created curve Return Value: Outcome object Notes: format can be something like "g:o" to represent green line, dotted line style, circle marker. this follows matlab's formatting rules. Code Example: {{{ x = list() y = list() for i in range(0,10) : x.append(i) y.append(pow(i,2)) p = Rappture.Plot() p.add(x, y, fmt="g:o", name="xsquared") # a single curve, named "xsquared", is stored in the plot object }}} p.add(c, name) Purpose: add a Curve object to this Plot object Input Arguments: 2 1. c - Curve object to add 2. name - id of the Curve object Return Value: Outcome object Notes: Curve object should not be deleted by user? Code Example: {{{ x = list() y = list() for i in range(0,10) : x.append(i) y.append(pow(i,2)) c = Rappture.Curve() c.axis(name="xvals", label="X Values", desc="Values along the X axis" val=x) c.axis(name="yvals", label="Y Values", desc="Values along the Y axis", val=y) p = Rappture.Plot() p.add(c, name="xsquared") # a single curve, named "xsquared", is stored in the plot object }}} p.count() Purpose: retrieve the number of curves in this Plot object Input Arguments: 0 Return Value: number of curves stored in the object Notes: None Code Example: {{{ x = list() y1 = list() y2 = list() for i in range(0,10) : x.append(i) y1.append(pow(i,2)) y2.append(pow(i,3)) } p = Rappture.Plot() p.add(x, y1, format="g:o", name="xsquared") p.add(x, y2, format="b-o", name="xcubed") print p.count() # 2 }}} p.curve(name) Purpose: retrieve the curve with the id matching "name" Input Arguments: 1 1. name - id to Curve to be retrieved Return Value: Curve object matching "name" or None Notes: None Code Example: {{{ x = list() y1 = list() y2 = list() for i in range(0,10) : x.append(i) y1.append(pow(i,2)) y2.append(pow(i,3)) } p = Rappture.Plot() p.add(x, y1, format="g:o", name="xsquared") p.add(x, y2, format="b-o", name="xcubed") c = p.curve("xsquared") print c.name() # xsquared }}} p.getNthCurve(n) Purpose: return the n'th curve stored in the object Input Arguments: 1 1. n - number of the curve to retrieve Return Value: the n'th Curve object stored in the Plot object or None Notes: None Code Example: {{{ x = list() y1 = list() y2 = list() for i in range(0,10) : x.append(i) y1.append(pow(i,2)) y2.append(pow(i,3)) } p = Rappture.Plot() p.add(x, y1, format="g:o", name="xsquared") p.add(x, y2, format="b-o", name="xcubed") c = p.getNthCurve(1) print c.name() # xcubed }}} p.vvalue([...]) Purpose: return the value of the object after applying a varying number of hints about how the value should be configured Input Arguments: variable numbber 1. variable number of hints Return Value: value of the object Notes: vvalue will parse out the recognisable hints from va_list arg. Values stored in the object are not changed. Hints should be of the form hintKey=hintVal Code Example: {{{ x = list() y1 = list() y2 = list() for i in range(0,10) : x.append(i) y1.append(pow(i,2)) y2.append(pow(i,3)) } p = Rappture.Plot() p.add(x, y1, format="g:o", name="xsquared") p.add(x, y2, format="b-o", name="xcubed") print p.vvalue() # [ [ [1 2 3 4 5 6 7 8 9 10] \ # [1 4 9 16 25 36 49 64 81 100] ] \ # [ [1 2 3 4 5 6 7 8 9 10] \ # [1 8 27 64 125 216 343 512 729 1000] ] ] }}} p.random(); Purpose: populate the object with a random value Input Arguments: 0 Return Value: None Notes: the current value of this object will be populated with a random value that fits within the min and max if they were specified. Code Example: {{{ p = Rappture.Plot() p.random() # plot is filed with random data print p.vvalue() # [ [ [1 2 3 4 5 6 7 8 9 10] \ # [1 2 3 4 5 6 7 8 9 10] ] \ # [ [1 2 3 4 5 6 7 8 9 10] \ # [1 4 9 16 25 36 49 64 81 100] ] \ # [ [1 2 3 4 5 6 7 8 9 10] \ # [1 8 27 64 125 216 343 512 729 1000] ] ] print p.count() # 3 }}} p.diff(o); Purpose: return a list showing the differences between this object and Rappture Object o Input Arguments: 1 1. o - Rappture Object to diff against Return Value: list of differences between objects Notes: None Code Example: {{{ p1 = Rappture.Plot() p1.random() # plot is filed with random data print p.vvalue() # [ [ [1 2 3 4 5 6 7 8 9 10] \ # [1 4 9 16 25 36 49 64 81 100] ] ] p2 = Rappture.Plot() p2.random() # plot is filed with random data print p.vvalue() # [ [ [1 2 3 4 5 6 7 8 9 10] \ # [1 8 27 64 125 216 343 512 729 1000] ] ] diffs = p1.diff(p2) # diffs is a list of tuples or list of lists. for ctype, prop, oVal, nVal in diffs { print "%s %s %s %s" % (ctype, prop, oVal, nVal)" } # c name temperature Ef # c units K eV # c def 300 4.5 # c min 0 0 # c max 500 10 # c label "Ambiant Temperature" "Fermi Level" # c desc "Temperature of the environment" "Energy at center of distribution" # # Note that this function will find a difference in the # minimum values even though they are numerically equal. # This is because the objects have different units that # are not compatible. If compatible units were found, # n2's values would have been converted to n1's units # for each comparison. # # if diffs is a flat list, user would need to write something like this: # for i in range(len(diffs)/4): # ctype, prop, oVal, nVal = diffs[(i*4):(i*4)+4] # print ctype, prop, oVal, nVal }}} p.configure(as, c) Purpose: configure the object based on the data in "c". use "as" to determine the type of data in "c". Input Arguments: 2 1. as - type of data stored in "c". valid values include: RPCONFIG_XML RPCONFIG_TREE 2. c - data to configure the object from. if as is... then c should be... RPCONFIG_XML const char *xmltext RPCONFIG_TREE RP_ParserXML *object Return Value: None Notes: object is configured based on values in "c" Code Example: {{{ p = Rappture.Plot() xmldata = """ auto34 x values are squared g:o values being squared linear squared values linear 1 1 2 4 3 9 4 16 5 25 6 36 7 49 8 64 9 81 10 100 auto34 x values are cubed b-o values being cubed linear cubed values linear 1 1 2 8 3 27 4 64 5 125 6 216 7 343 8 512 9 729 10 1000 """ p.configure(RPCONFIG_XML,xmldata) print p.vvalue() # [ [ [1 2 3 4 5 6 7 8 9 10] \ # [1 4 9 16 25 36 49 64 81 100] ] \ # [ [1 2 3 4 5 6 7 8 9 10] \ # [1 8 27 64 125 216 343 512 729 1000] ] ] for cur in range(p.count()): c = p.getNthCurve(cur) print c.name() print c.label() print c.desc() print c.format() for axisCnt in range(c.dims()): axis = c.getNthAxis(axisCnt) print axis.label() print axis.desc() print axis.units() print axis.scale() print axis.data() # xsquared # x squared # x values are squared # g:o # xaxis # x values # values being squared # # linear # [1 2 3 4 5 6 7 8 9 10] # yaxis # y values # squared values # # linear # [1 4 9 16 25 36 49 64 81 100] # xcubed # x cubed # x values are cubed # b-o # xaxis # x values # values being cubed # # linear # [1 2 3 4 5 6 7 8 9 10] # yaxis # y values # cubed values # # linear # [1 8 27 64 125 216 343 512 729 1000] }}} p.dump(as, c) Purpose: dump the object values based to the object "c". use "as" to determine how to dump the data. Input Arguments: 2 1. as - type of data stored in "c". valid values include: RPCONFIG_XML RPCONFIG_TREE 2. c - data to configure the object from. if as is... then c should be... RPCONFIG_XML ClientDataXml *object RPCONFIG_TREE RP_ParserXML *object Return Value: None Notes: None Code Example: {{{ x = list() y1 = list() y2 = list() for i in range(0,10) : x.append(i) y1.append(pow(i,2)) y2.append(pow(i,3)) } p = Rappture.Plot() p.add(x, y1, format="g:o", name="xsquared") p.add(x, y2, format="b-o", name="xcubed") print p.dump(RPCONFIG_XML) # # # auto34 # # # (null) # g:o # # # # # # linear # # # # # # linear # # # 1 1 # 2 4 # 3 9 # 4 16 # 5 25 # 6 36 # 7 49 # 8 64 # 9 81 # 10 100 # # # # # # unnamed # # # (null) # b-o # # # # # # linear # # # # # # linear # # # 1 1 # 2 8 # 3 27 # 4 64 # 5 125 # 6 216 # 7 343 # 8 512 # 9 729 # 10 1000 # # # }}} p.outcome() Purpose: return the status of this object as an Outcome. Input Arguments: 0 Return Value: status of the object as an Outcome Notes: None Code Example: {{{ p = Rappture.Plot() out = p.outcome() if (out.value() != 0) { sys.stderr.write(out.context()) sys.stderr.write(out.remark()) } }}} p.is() Purpose: return an integer tag describing the object. Input Arguments: 0 Return Value: integer tag unique to all number objects Notes: None Code Example: