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.
result = machine.run_code("""import matplotlib.pyplot as pltplt.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: