
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Draw Rounded Line Ends Using Matplotlib
To draw rounded line ends using matplotlib, we can use solid_capstyle='round'.
Steps
- Set the figure size and adjust the padding between and around the subplots.
- Create random x and y data points using numpy.
- Create a figure and a set of subplots.
- Plot x and y data points using plot() method, with solid_capstyle in the method argument.
- To display the figure, use show() method.
Example
import matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.random.randn(5) y = np.random.randn(5) fig, ax = plt. subplots() ln, = ax.plot(x, y, lw=10, solid_capstyle='round', color='red') plt.show()
Output
Advertisements