- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 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
- Related Articles
- How can I draw a scatter trend line using Matplotlib?
- How to draw a line outside of an axis in Matplotlib?
- How can I draw inline line labels in Matplotlib?
- How to draw a rounded Rectangle on HTML Canvas?
- How to draw an average line for a scatter plot in MatPlotLib?
- How to create a line chart using Matplotlib?
- How to draw a line in OpenCV using Java?
- How to draw a line in Android using Kotlin?
- How to draw a line in OpenCV using C++?
- How can we draw a rounded rectangle using the Graphics object in Java?
- How to draw an arrowed line in OpenCV using Java?
- How to draw a line using imageline() function in PHP?
- How to draw a smooth line following my finger using Kotlin?
- How to get alternating colours in a dashed line using Matplotlib?
- Draw parametrized curve using pyplot.plot() in Matplotlib

Advertisements