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

# Beyond Matplotlib -- Declarative plotting in Python

Plotting is a crucial part of bioinformatics and computational biology -- it serves as both a starting place, through exploratory data analysis, and the endpoint of a data workflow.

One of the most well-known plotting libraries in Python is **Matplotlib**. It was one of the first widely-adopted plotting libraries in Python and is used as the plotting package within many domain-specific analysis packages, such as Scanpy.

Matplotlib supports a wide variety of plot types and allows for extremely fine-grained control over plot styling, which makes it a great choice for producing publication-ready plots.

However, this level of control is a double-edged sword. Its syntax can be quite verbose. Because Matplotlib uses the imperative programming paradigm, you need to explicitly define the construction of each visualization, with step-by-step commands, from the axes to the marks to the labels and legends.

Many bioinformaticians and computational biologists who are familiar with the ggplot package in R, which uses a declarative programming paradigm, find the procedural nature of plotting with Matplotlib to be quite onerous.

In this notebook, we briefly introduce a few declarative plotting packages that may allow you to more quickly jump into exploratory data analysis or modify figures as needed for presentations or reports.

We use the [Palmer Penguins](https://allisonhorst.github.io/palmerpenguins/) dataset as our dataset.

> Data were collected and made available by Dr. Kristen Gorman and the Palmer Station, Antarctica LTER, a member of the Long Term Ecological Research Network.

We demonstrate how to create a scatter plot of flipper length vs. body mass, colored by penguin species, in Matplotlib, Seaborn, Plotnine, Vega-Altair, and Holoviews.

<CardGroup cols={2}>
  <Card title="Seaborn">
    <img src="https://mintcdn.com/mantlebio/LUzPTXQRsMt8_AfM/workflows/assets/declarative_plotting_seaborn.png?fit=max&auto=format&n=LUzPTXQRsMt8_AfM&q=85&s=9d0c684f36545eec4a20a03bc7ebae07" width="1366" height="1300" data-path="workflows/assets/declarative_plotting_seaborn.png" />
  </Card>

  <Card title="Plotnine">
    <img src="https://mintcdn.com/mantlebio/LUzPTXQRsMt8_AfM/workflows/assets/declarative_plotting_plotnine.png?fit=max&auto=format&n=LUzPTXQRsMt8_AfM&q=85&s=fa9e40f7db58ad9e4c5f83250ba433be" width="1372" height="1216" data-path="workflows/assets/declarative_plotting_plotnine.png" />
  </Card>

  <Card title="Vega-Altair">
    <img src="https://mintcdn.com/mantlebio/LUzPTXQRsMt8_AfM/workflows/assets/declarative_plotting_altair.png?fit=max&auto=format&n=LUzPTXQRsMt8_AfM&q=85&s=2031aec0b35902b547714f90a811d184" width="1382" height="938" data-path="workflows/assets/declarative_plotting_altair.png" />
  </Card>

  <Card title="Holoviews">
    <img src="https://mintcdn.com/mantlebio/LUzPTXQRsMt8_AfM/workflows/assets/declarative_plotting_holoviews.png?fit=max&auto=format&n=LUzPTXQRsMt8_AfM&q=85&s=35aa9ddb2cb216a55b3249ed888a4289" width="1376" height="1102" data-path="workflows/assets/declarative_plotting_holoviews.png" />
  </Card>
</CardGroup>
