- 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 put a title for a curved line in Python Matplotlib?
To put a title for a curved line in Python Matplotlib, we can take the following steps −
Steps
Set the figure size and adjust the padding between and around the subplots.
Create x and y data points such that the line would be a curve.
Plot the x and y data points.
Place a title for the curve plot using plt.title() method.
To display the figure, use Show() method.
Example
import matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Create x and y data points x = np.linspace(-1, 1, 50) y = 2**x + 1 # Plot the x and y data points line, = plt.plot(x, y) # Place a title on the plot plt.title("$y=2^x+1$") plt.show()
Output
It will produce the following output −
- Related Articles
- How to put the title at the bottom of a figure in Matplotlib?
- How to label a line in Matplotlib (Python)?
- How to put multi-line comments inside a Python dict()?
- How to put xtick labels in a box matplotlib?
- How to draw an average line for a scatter plot in MatPlotLib?
- How to add a title to an existing line border in Java?
- How to animate a line plot in Matplotlib?
- How to pick a new color for each plotted line within a figure in matplotlib?
- How do I put a circle with annotation in matplotlib?
- How to set a title above each marker which represents a same label in Matplotlib?
- How to plot a bar chart for a list in Python matplotlib?
- How to plot a 3D continuous line in Matplotlib?
- How to plot a gradient color line in matplotlib?
- How to put the Origin at the center of the cos curve in a figure in Python Matplotlib?
- How to create a line chart using Matplotlib?

Advertisements