> For the complete documentation index, see [llms.txt](https://particle-analytics-1.gitbook.io/iota-python-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://particle-analytics-1.gitbook.io/iota-python-api/19.2.1/iota/session_graph.md).

# Graph

`iota.graph.Graph()`

**Description** Iota graph object.

**Methods**

* [`export_html`](/iota-python-api/19.2.1/iota/session_graph.md#export_html)
* [`get_axis_title`](/iota-python-api/19.2.1/iota/session_graph.md#get_axis_title)
* [`get_data`](/iota-python-api/19.2.1/iota/session_graph.md#get_data)
* [`get_labels`](/iota-python-api/19.2.1/iota/session_graph.md#get_labels)
* [`get_legend`](/iota-python-api/19.2.1/iota/session_graph.md#get_legend)

**Static methods**

* [`default_export_layout`](/iota-python-api/19.2.1/iota/session_graph.md#default_export_layout)
* [`export_plotly`](/iota-python-api/19.2.1/iota/session_graph.md#export_plotly)

&#x20;**Variables**

* `description` (str) user description
* `filepath` (str) file containing the graph data (csv format)
* `name` (str) graph name

## Methods

### [export\_html(output\_file,\[layout\])](/iota-python-api/19.2.1/iota/session_graph.md#export_html) <a href="#export_html" id="export_html"></a>

*Generate a html document, containing the plots for a graph*

**Arguments**

* `output_file`: (text) file path where the html graph will be saved
* `layout`: (dict) layout used to generate the graph (Default: **None**)

**Example**

```python
>>> 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\_axis\_title()](/iota-python-api/19.2.1/iota/session_graph.md#get_axis_title) <a href="#get_label" id="get_label"></a>

*Get xtitle,ytitle pair from the graph*

**Example**

```python
>>> xtitle,ytitle = my_graph.get_axis_title()
>>> print(xtitle)
timestep
>>> print(ytitle)
Solid Fraction
```

### [get\_data()](/iota-python-api/19.2.1/iota/session_graph.md#get_data) <a href="#get_data" id="get_data"></a>

Get the raw underlying data of a graph return an `OrderedDict` of pairs { 'column\_name' : ArrayFloat() }

**Example**

```python
>>> 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]}
]
```

### [get\_labels()](/iota-python-api/19.2.1/iota/session_graph.md#get_labels) <a href="#get_labels" id="get_labels"></a>

Returns list of labels of graph curves (xtitle and trace labels)

**Example**

```python
>>> labels = my_graph.get_labels()
>>> print(labels)
['timestep','curve 1','curve 2']
```

### [get\_legend()](/iota-python-api/19.2.1/iota/session_graph.md#get_legend) <a href="#get_legend" id="get_legend"></a>

Get the label of each trace in the graph

**Example**

```python
>>> legends = my_graph.get_legend()
>>> print(legends)
['curve 1','curve 2']
```

## Static methods

### [default\_export\_layout()](/iota-python-api/19.2.1/iota/session_graph.md#default_export_layout) <a href="#default_export_layout" id="default_export_layout"></a>

Returns the dictionary containing the default layout used if nothing defined by the user

**Example**

```python
>>> layout = Graph.default_export_layout()
>>> print(layout)
{
  'width': 800,
  'height': 640
}
```

### [export\_plotly(file, data, \[layout\])](/iota-python-api/19.2.1/iota/session_graph.md#export_plotly) <a href="#export_plotly" id="export_plotly"></a>

Generate a html graph file invoking directly plotly

**Arguments**

* `file`: (text) file path where the html graph will be saved
* `data`: (dict) data to be plotted
* `layout`: (dict) layout used to generate the graph (Default: **None**)

**Example**

```python
>>> 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
    )
```
