import pandas as pd
measurements = pd.read_csv("data/measurements.csv")
measurements| plant | week | height_cm | |
|---|---|---|---|
| 0 | Basil | 1 | 4 |
| 1 | Basil | 2 | 7 |
| 2 | Basil | 3 | 10 |
| 3 | Basil | 4 | 14 |
| 4 | Mint | 1 | 5 |
| 5 | Mint | 2 | 8 |
| 6 | Mint | 3 | 12 |
| 7 | Mint | 4 | 17 |
Choose Run in browser, then use Run > Run All Cells in JupyterLite. The bundle includes this notebook and its CSV file.
The sample file holds invented measurements for two plants.
Its path stays data/measurements.csv in the browser and in the download.
import pandas as pd
measurements = pd.read_csv("data/measurements.csv")
measurements| plant | week | height_cm | |
|---|---|---|---|
| 0 | Basil | 1 | 4 |
| 1 | Basil | 2 | 7 |
| 2 | Basil | 3 | 10 |
| 3 | Basil | 4 | 14 |
| 4 | Mint | 1 | 5 |
| 5 | Mint | 2 | 8 |
| 6 | Mint | 3 | 12 |
| 7 | Mint | 4 | 17 |
Seaborn draws one line for each plant. The first code cell in the browser copy installs the packages found in the imports.
import matplotlib.pyplot as plt
import seaborn as sns
fig, ax = plt.subplots(figsize=(7, 3.5))
sns.lineplot(data=measurements, x="week", y="height_cm", hue="plant", marker="o", ax=ax)
ax.set(xlabel="Week", ylabel="Height (cm)", title="Example plant measurements")
ax.set_xticks([1, 2, 3, 4])
fig.tight_layout()
plt.show()Change the plot to sns.scatterplot and remove marker="o".
Run that cell again to draw separate points.