Quarto - Matplotlib Charts

12/01/2024, Sun
Categories: #Python
Tags: #quarto

Hide Code Description Display and Chart and Render Svg Charts Instead

The Matplotlib charting outputs unwanted content in your document related to the description of chart. Something similar to this might appear right above the chart that you want to display.

<Figure size 960x576 with 0 Axes>

To remedy this issue, add #| output: false right after the start of the block definition for code blocks that use Matplotlib to plot a chart.

```{python}
#| output: false

# Your matplotlib charting logic

# Output chart to svg image format
plt.savefig('./images/my_chart.svg', format='svg')
```

Now you can reference this image to display the chart without the extraneous chart output.

![My Chart](./images/my_chart.svg)