
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Add Caption Below X-Axis for Scatter Plot Using Matplotlib
To add caption below X-axis for a scatter plot, we can use text() method for the current figure.
Steps
Create x and y data points using numpy.
Create a new figure or activate an existing figure using figure() method.
Plot the scatter points with x and y data points.
To add caption to the figure, use text() method.
Adjust the padding between and around the subplots.
To display the figure, use show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True x = np.random.rand(10) y = np.random.rand(10) fig = plt.figure() plt.scatter(x, y, c=y) fig.text(.5, .0001, "Scatter Plot", ha='center') plt.tight_layout() plt.show()
Output
Advertisements