How to do a scatter plot with Matplotlib

1 min

Here is the simplest method to do a scatter plot.

import matplotlib.pyplot as plt
import pandas as pd

# We create our dataframe
df = pd.DataFrame(index=range(0,10), data={"col1" : range(0,10)})

fig, axes = plt.subplots(1,1, figsize=(8,6))

# We do a scatter plot on the axes
axes.scatter(df.index, df["col1"])

# Fixing the layout to fit the size

# Showing the plot
The method using matplotlib

More on plots

If you want to know more about how to add labels, plot different types of plots, etc... checkout the other articles I wrote on the topic, just here :

Matplotlib - The Python You Need
We gathered the only Python essentials that you will probably ever need.