> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ns.rocks/llms.txt
> Use this file to discover all available pages before exploring further.

# Static charts

> Generate PNG and file-based chart outputs with Python plotting libraries.

Use Matplotlib, Seaborn, or another installed Python plotting library for static
charts. Displayed figures are returned as rich notebook outputs, and saved files
are available through artifacts or normal filesystem reads.

```python theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
result = machine.run_code("""
import matplotlib.pyplot as plt

plt.figure(figsize=(4, 3))
plt.bar(["A", "B", "C"], [3, 7, 5])
plt.title("Example chart")
plt.tight_layout()
plt.savefig("/workspace/chart.png")
plt.show()
""")

png_outputs = [
    item for item in result.results
    if item.png or (item.data and "image/png" in item.data)
]
print(len(png_outputs))
```

Rich result objects (`item.png`, `item.data`) are SDK-only. Via the CLI or HTTP
API, save the figure to a file (as above) and fetch it with `code artifact
download` or a filesystem read.

Download a saved chart from the machine:

```python theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
chart_bytes = machine.files.read("/workspace/chart.png", format="bytes")
```

## Related

* [Filesystem downloads](../filesystem/downloads)
* [Runs and artifacts](./runs-artifacts)
