- 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 remove a specific line or curve in Matplotlib?
To remove a specific line or curve in Matplotlib, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Plot line1 and line2 using plot() method.
- Pop the second line and remove it.
- To display the figure, use show() method.
Example
from matplotlib import pyplot as plt, image as mimg plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True line_1 = plt.plot([1, 2, 3]) line_2 = plt.plot([2, 4, 6]) line = line_2.pop(0) line.remove() plt.show()
Output
- Related Articles
- How to animate a sine curve in Matplotlib?
- How to add a cursor to a curve in Matplotlib?
- How to fill color below a curve in Matplotlib?
- Draw a curve connecting two points instead of a straight line in matplotlib
- How to curve text in a polar plot in matplotlib?
- How to fill rainbow color under a curve in Python Matplotlib?
- How to change the curve using radiobuttons in Matplotlib?
- How to assign specific colors to specific cells in a Matplotlib table?
- How to draw a precision-recall curve with interpolation in Python Matplotlib?
- How to fill color above the curve in Matplotlib Program?
- How to remove lines in a Matplotlib plot?
- How to remove or hide X-axis labels from a Seaborn / Matplotlib plot?
- Draw a parametrized curve using pyplot.plot() in Matplotlib
- How to label a line in Matplotlib (Python)?
- How to animate a line plot in Matplotlib?

Advertisements