- 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 plot overlapping lines in Matplotlib?
To plot overlapping lines in matplotlib, we can use variable overlapping that basically sets the opacity or alpha value in the plot.
- Set the figure size and adjust the padding between and around the subplots.
- Initialize a variable overlapping to set the alpha value of the line.
- Plot line1 and line2 with red and green colors, respectively, with the same alpha value.
- To display the figure, use show() method.
from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True overlapping = 0.150 line1 = plt.plot([1, 3, 5, 2, 5, 3, 1], c='red', alpha=overlapping, lw=5) line2 = plt.plot([7, 2, 5, 7, 5, 2, 7], c='green', alpha=overlapping, lw=5) plt.show()
- How to remove lines in a Matplotlib plot?
- How to draw axis lines inside a plot in Matplotlib?
- Matplotlib Plot Lines with Colors through Colormap
- How to plot the lines first and points last in Matplotlib?
- How to name different lines in the same plot of Matplotlib?
- How to add vertical lines to a distribution plot (sns.distplot) in Matplotlib?
- How to plot two dotted lines and set marker using Matplotlib?
- How to avoid overlapping error bars in matplotlib?
- How to hide lines in Matplotlib?
- Best way to plot an angle between two lines in Matplotlib
- How to set same color for markers and lines in a Matplotlib plot loop?
- Draw axis lines or the origin for Matplotlib contour plot.
- How to change the color and add grid lines to a Python Matplotlib surface plot?
- How to plot matplotlib contour?
- How to get multiple overlapping plots with independent scaling in Matplotlib?