Use DataFrame.plot.scatter() to plot one pandas column against another: set x to the horizontal column and y to the vertical column. For example, df.plot.scatter(x="height", y="weight") creates a scatter plot from those two numeric columns and returns Matplotlib axes you can format.
Create a scatter plot from two columns
Each row in the DataFrame represents an observation; its values in the selected columns determine that point’s horizontal and vertical coordinates. The pandas visualization guide specifies numeric columns for both axes. Use the exact column labels, or integer column positions, in the call.
ax = df.plot.scatter(x="hours_studied", y="exam_score")
The API reference documents DataFrame.plot.scatter in pandas 3.0.5, and the visualization guide retrieved for this article is labeled pandas 3.0.6. These are documentation versions, not a claim about the version installed in your environment. See the pandas scatter plot API and pandas chart visualization guide.
Format the plot
The method returns a Matplotlib Axes object, which you can keep in a variable and use to set labels and a title. Pandas plotting also forwards supported keyword arguments to Matplotlib.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →#1 Best Overall
ax = df.plot.scatter(x="hours_studied", y="exam_score")
ax.set_title("Study time and exam score")
ax.set_xlabel("Hours studied")
ax.set_ylabel("Exam score")
For a complete display example, import Matplotlib’s pyplot module and call show(). Add tight_layout() if you want Matplotlib to adjust spacing around the labels.
import matplotlib.pyplot as plt
ax = df.plot.scatter(
x="height",
y="weight",
s=40,
alpha=0.6,
title="Height and weight",
)
ax.set_xlabel("Height (cm)")
ax.set_ylabel("Weight (kg)")
plt.tight_layout()
plt.show()
This is an API example; its values illustrate options rather than prescribe a universally suitable marker size or transparency.
Use color or size to show a third variable
Marker size and color can encode additional data. The scatter API documents s as accepting a scalar, array-like values, or a column name. The c argument accepts a color, color sequence, or a column whose values are mapped through a colormap.
s=40gives points a uniform size; use a size column or array when marker area should reflect a meaningful measure.c="group_code"maps the values in that column to colors; add a colormap such ascolormap="viridis"to specify the scale.- When color represents data, explain what the colors mean and include a colorbar or other clear key where it helps readers interpret the plot.
ax = df.plot.scatter(
x="height",
y="weight",
c="group_code",
colormap="viridis",
)
Transparency, set with alpha, can help reveal overlapping points. Matplotlib’s gallery demonstrates alpha=0.5 and marker areas passed through s; the appropriate settings depend on the data and chart. See the Matplotlib scatter plot example.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Rank #3
Check missing values and point overlap
Missing values
The pandas visualization guide says scatter plots drop missing values. A plot may therefore contain fewer points than the DataFrame has rows. Check missing values in the selected columns and decide whether omitting those observations affects how you interpret the relationship.
Dense point clouds
If many points overlap, individual observations can become difficult to distinguish. Consider DataFrame.plot.hexbin, which the pandas guide identifies as useful when data are too dense to plot point by point. Compare whether it communicates the density more clearly than the scatter plot for your question.
Rank #4
- Crisp writing pages are perfect for personal reflections, sketching, or for recording favorite quotations or poems.
- Premium 120 gsm paper takes pen or pencil beautifully.
- Paper is acid free and of archival quality.
- Light gray lines subtly guide your writing.
- An inside back cover pocket expands to hold notes, cards, mementos, and more.
When you need to compare many columns
A single scatter plot is suited to a focused comparison between two variables. If you want to inspect pairwise relationships across several numeric columns, pandas.plotting.scatter_matrix creates a grid of pairwise scatter plots and places histograms or KDE plots along the diagonal. Use the single plot when you need to focus on one relationship; use the matrix when broader pairwise exploration is the goal. The pandas visualization guide describes hexbin plots and scatter matrices.
Quick Recap
Best Value
- Funny design. Import pandas as pd, an all too familiar python code.
- Featuring a familiar python code, this will get a laugh from all the nearby programmers and GIS professionals.
- Lightweight, Classic fit, Double-needle sleeve and bottom hem
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Recommended Free Tools




