Libraries & Dataset

Let's start by loading the necessary libraries and create a dataset

  • matplotlib: for displaying the plot
  • pandas: for data manipulation
  • numpy: for data generation
# libraries
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

# Create a dataset:
df = pd.DataFrame({
    'x_values': range(1, 101),
    'y_values': np.random.randn(100)*15+range(1, 101)
x_values y_values
0 1 16.036968
1 2 -11.666240
2 3 8.503309
3 4 7.816552
4 5 -0.893881

Most simple scatter plot

This is a basic scatterplot example made with the scatter() function of Matplotlib. These arguments are passed to the function:

  • x : column name to be used for the x axis
  • y : column name to be used for the y axis
  • data : the dataset to be used
  • linestyle : style of the lines between each point
  • marker : marker style of the points
fig, ax = plt.subplots()
    'x_values', 'y_values',

Going further

This post explains how to create a scatter plot with Matplotlib.

You might be interested in how to custom markers in scatter plots and how to link title and markers in scatter plots.

Contact & Edit

👋 This document is a work by Yan Holtz. You can contribute on github, send me a feedback on twitter or subscribe to the newsletter to know when new examples are published! 🔥

This page is just a jupyter notebook, you can edit it here. Please help me making this website better 🙏!