- 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
Can I give a border to a line in Matplotlib plot function?
To give a border to a line in matplotlib plot function, we can call plot() function twice with varying line width.
- Set the figure size and adjust the padding between and around the subplots.
- Create x and y data points using numpy.
- Plot x and y data points where line width=10 and color=black.
- Again plot x and y points where line width=8 and color=red.
- To display the figure, use show() method.
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-2, 2, 100) y = np.sin(x) plt.plot(x, y, c='black', lw=10) plt.plot(x, y, c='red', lw=8) plt.show()
- How can I plot a confusion matrix in matplotlib?
- How to animate a line plot in Matplotlib?
- How can I place a table on a plot in Matplotlib?
- How can I plot a single point in Matplotlib Python?
- How to plot a smooth line with matplotlib?
- How can I create a stacked line graph with matplotlib?
- How can I make a simple 3D line with Matplotlib?
- How can I draw a scatter trend line using Matplotlib?
- How to plot a gradient color line in matplotlib?
- How to plot a 3D continuous line in Matplotlib?
- How do I plot a step function with Matplotlib in Python?
- Add a custom border to certain cells in a Matplotlib / Seaborn plot
- How can I get the (x,y) values of a line that is plotted by a contour plot (Matplotlib)?
- How can I plot hysteresis threshold in Matplotlib?
- How can I attach a pyplot function to a figure instance? (Matplotlib)