- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to label bubble chart/scatter plot with column from Pandas dataframe?
To label bubble charts/scatter plot with column from Pandas dataframe, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Create a data frame, df, of two-dimensional, size-mutable, potentially heterogeneous tabular data.
- Create a scatter plot with df.
- Annotate each data point with a text.
- To display the figure, use show() method.
Example
import pandas as pd from matplotlib import pyplot as plt # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Create a dataframe df = pd.DataFrame( dict( x=[1, 3, 2, 4, 5], y=[0, 3, 1, 2, 5], points=['Kiran', 'Raju', 'Raja', 'Javed', 'Rishi'] ) ) # Scatter plot ax = df.plot.scatter(x='x', y='y', alpha=0.5) # Annotate each data point for i, txt in enumerate(df.points): ax.annotate(txt, (df.x.iat[i]+0.05, df.y.iat[i])) plt.show()
Output
It will produce the following output
- Related Articles
- Python - Plot a Pie Chart for Pandas Dataframe with Matplotlib?
- Python - Draw a Scatter Plot for a Pandas DataFrame
- How to improve the label placement for Matplotlib scatter chart?
- How to plot a Pandas Dataframe with Matplotlib?
- How to delete a column from Pandas DataFrame
- Create a Scatter Plot with SeaBorn – Python Pandas
- How to delete a column from a Pandas DataFrame?
- How to add column from another DataFrame in Pandas?
- How to add a shared x-label and y-label to a plot created with Pandas' plot? (Matplotlib)
- Python - How to select a column from a Pandas DataFrame
- Plot multiple columns of Pandas dataframe on the bar chart in Matplotlib
- Python Pandas - How to select rows from a DataFrame by passing row label
- How to plot aggregated by date pandas dataframe?
- How to plot a Pandas multi-index dataFrame with all xticks (Matplotlib)?
- Merge Pandas DataFrame with a common column

Advertisements