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()