> For the complete documentation index, see [llms.txt](https://calctree.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://calctree.gitbook.io/docs/calculations/creating-calculations/python/tables-and-visuals.md).

# Tables and visuals

Display tabular data and visual outputs directly from your Python calculations using list-based tables and matplotlib figures.

Python sources in CalcTree support both **tabular data** and **visual outputs** such as plots and charts. This allows you to include structured results and engineering figures directly within your calculation pages.

### Creating Tables

To create a table, define a root-level Python variable as a list of lists. Each inner list will be treated as a row in the table.

**Example:**

```python
my_table = [
    [1, "apple"],
    ["cat", 3.14]
]
```

This will display a 2-row table under the Python source block on the right-hand panel.

### Generating Visuals

You can use the `matplotlib` library to create charts and plots. If your Python source includes a `matplotlib` figure, CalcTree will automatically detect and display it below the script.

**Example:**

```python
import matplotlib.pyplot as plt
import numpy as np

# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)

fig, ax = plt.subplots()
ax.plot(t, s)

ax.set(xlabel='time (s)', ylabel='voltage (mV)',
       title='Sine Wave Example')
ax.grid()
```

The figure will appear in the Variables panel. Click the three-dot menu, and 'Mention in page' to add the figure anywhere on your page.

<figure><img src="https://94933883-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS1yC9mBIPsA0bB8PMGaq%2Fuploads%2FI93wgEAPLgM3WGJ8eB67%2Fimage.png?alt=media&amp;token=a56c317b-40df-43d9-85de-64c3f2a9b857" alt=""><figcaption></figcaption></figure>

### Notes

* Only `matplotlib` figures are currently supported
* Tables must be declared as simple list-of-list objects at the root level
* Both outputs update live as you edit your code or variables on the page linked to these elements

{% hint style="info" %}
You can learn more about creating various charts or diagrams using the Matplotlib library [here](https://matplotlib.org/stable/)
{% endhint %}
