- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 −
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.
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()
It will produce the following output −
- How to put the title at the bottom of a figure in Matplotlib?
- How to put multi-line comments inside a Python dict()?
- How to label a line in Matplotlib (Python)?
- How to put xtick labels in a box matplotlib?
- How to draw an average line for a scatter plot in MatPlotLib?
- How to animate a line plot in Matplotlib?
- Creating curved edges with NetworkX in Python3 (Matplotlib)
- How to add a title to an existing line border in Java?
- 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?
- Plot a Line Graph for Pandas Dataframe with Matplotlib?
- How to create a line chart using Matplotlib?
- How to plot a smooth line with matplotlib?
- How to plot a gradient color line in matplotlib?
- How to plot a 3D continuous line in Matplotlib?