Graph
iota.graph.Graph()
Description Iota graph object.
Methods
Static methods
Variables
description
(str) user descriptionfilepath
(str) file containing the graph data (csv format)name
(str) graph name
Methods
Generate a html document, containing the plots for a graph
Arguments
output_file
: (text) file path where the html graph will be savedlayout
: (dict) layout used to generate the graph (Default: None)
Example
>>> my_graph = project.get_graph('MyNewGraph')
>>> my_graph.export_html(
output_file = 'c:\User\particle\Desktop\my_new_graph.html',
layout = dict(
xaxis = dict(
range = [0, 20]
)
)
)
Get xtitle,ytitle pair from the graph
Example
>>> xtitle,ytitle = my_graph.get_axis_title()
>>> print(xtitle)
timestep
>>> print(ytitle)
Solid Fraction
Get the raw underlying data of a graph return an OrderedDict
of pairs { 'column_name' : ArrayFloat() }
Example
>>> my_graph = project.get_graph('Reaction Torque (base).empty')
>>> data = my_graph.get_data()
>>> print(data)
[
{'Time': [0,1,2,3]},
{'Torque': [0.0,0.0,0.0,0.0]}
]
Returns list of labels of graph curves (xtitle and trace labels)
Example
>>> labels = my_graph.get_labels()
>>> print(labels)
['timestep','curve 1','curve 2']
Get the label of each trace in the graph
Example
>>> legends = my_graph.get_legend()
>>> print(legends)
['curve 1','curve 2']
Static methods
Returns the dictionary containing the default layout used if nothing defined by the user
Example
>>> layout = Graph.default_export_layout()
>>> print(layout)
{
'width': 800,
'height': 640
}
Generate a html graph file invoking directly plotly
Arguments
file
: (text) file path where the html graph will be saveddata
: (dict) data to be plottedlayout
: (dict) layout used to generate the graph (Default: None)
Example
>>> my_data = [
{
'x': list(xdata),
'y': list(ydata[0]),
'legendgroup': 'group', # this can be any string, not just "group"
'name': 'ydata_value',
'mode': 'lines',
'marker': {
'color': 'rgb(164, 194, 244)'
}
},
{
'x': list(xdata),
'y': list(ydata2),
'legendgroup': 'group', # this can be any string, not just "group"
'name': 'ydata_value squared',
'mode': 'lines+markers',
'marker': {
'color': 'rgb(142, 124, 195)'
},
'line': {
'width': 3
}
}
]
>>> my_layout = {
'title': 'Advanced plotly graph'.title(),
'xaxis': {
'title': xtitle.title(),
'showgrid': True,
'showline': True,
'zeroline': True,
'mirror': 'ticks'
},
'yaxis': {
'title': ytitle.title(),
'showgrid': True,
'showline': True,
'zeroline': True,
'mirror': 'ticks',
'type': 'log',
'autorange':True
}
}
>>> Graph.export_plotly(
file = 'C:\Users\particle\Desktop\my_graph.html',
data = my_data,
layout = my_layout
)
Last updated
Was this helpful?