simetrix.Graph¶
- class simetrix.Graph¶
Bases:
GraphObjectRepresents a graph.
A graph contains a set of curves.
Methods
curves()Returns a list containing all Curve objects owned by the graph.
newGrid(options)Creates new grid in the graph.
objects()Returns a list containing all GraphObject objects owned by the graph.
objectsOfType(type)Returns a list containing all GraphObject objects of the given type owned by the graph.
prop(propertyName)Returns the property with the name given.
Returns the set of properties for this object.
Returns a list containing all GraphObject objects owned by the graph which are currently selected.
selectedObjectsOfType(type)Returns a list containing all GraphObject objects of the given type owned by the graph and which are currently selected.
setPropertyValue(propertyName, propertyValue)Sets a property value for an object.
Attributes
Returns the ID of the object.
Returns the currently selected grid in the graph.
Returns the object type.
Returns True if the GraphObject is valid.
- property id: int¶
Returns the ID of the object. This can be used to pass to a native SIMetrix script function.
- newGrid(options: list[GridOptions]) PlotReturnData¶
Creates new grid in the graph. Optionally the grid may be defined as digital or/and detached. A digital grid is designed to plot digital waveforms and is physically small allowing many such grids to be included in a single graph sheet. A detached grid is one with an independent x-axis
- objects() list[GraphObject]¶
Returns a list containing all GraphObject objects owned by the graph. This includes,
Curve,GridandAxisobjects as well an any annotation objects present.
- objectsOfType(type: GraphObjectType) list[GraphObject]¶
Returns a list containing all GraphObject objects of the given type owned by the graph.
- prop(propertyName: str) GraphProperty¶
Returns the property with the name given. Can also use property().
Some properties have a symbolic value denoted by enclosing the value with ‘%’ characters. The property method will return the resolved value instead of the symbolic value if the name is prefixed with the ‘@’ character. For example:
print(curve.prop('@Label').Value)
The Label property usually has the value %DefaultLabel% which is what would be returned by the method if the ‘@’ character were omitted. The resolved value is the value of the DefaultLabel property.
- properties() list[GraphProperty]¶
Returns the set of properties for this object.
Example
Print the name and data type for all properties belonging to the current graph.
import simetrix as sx graph = sx.currentGraph() props= graph.properties() for p in props : print(p.name, p.type)
- property selectedGrid: Grid¶
Returns the currently selected grid in the graph. There is always one and one only selected grid in every graph. Visually this is identified by the presence of two vertical lines to the left of the y-axis.
- selectedObjects() list[GraphObject]¶
Returns a list containing all GraphObject objects owned by the graph which are currently selected.
- selectedObjectsOfType(type: GraphObjectType) list[GraphObject]¶
Returns a list containing all GraphObject objects of the given type owned by the graph and which are currently selected.
- setPropertyValue(propertyName: str, propertyValue: str | float)¶
Sets a property value for an object.
As explained in
GraphPropertyGraphProperty obejcts can have one of five data types. However, writeable properties can only be scalar string or scalar real valued. Hence this method can only accept real or string data for the property value.Example
import simetrix as sx # Get the current graph graph = sx.currentGraph() # Get the first curve available curve = graph.curves()[0] # Change the curve colour to green curve.setPropertyValue('RGBColour', 32768)
- property type: GraphObjectType¶
Returns the object type.
- property valid: bool¶
Returns True if the GraphObject is valid.
A GraphObject obtained from the GraphProperty of another GraphObject will not necessarily be valid. The following example obtains the MainCursor property of the current graph. This will be an invalid object if cursors are not enabled.
import simetrix as sx graph = sx.currentGraph() mainCursor = graph.prop('MainCursor') if mainCursor.value.valid : print("Cursors are enabled") else : print("Cursors are not enabled")