Cap styles

Another parameter for tuning is dash_capstyle. It controls the style of the dash ends:

  • 'butt': Blunt end
  • 'projecting': Extends in length
  • 'round': Rounded end

To demonstrate the different cap styles, we have a code snippet of a multiline plots with thick lines to enlarge the dashes:

import matplotlib.pyplot as plt

# Prepare 4 data series of sine curves
y = list(range(10))

dash_capstyles = ['butt','projecting','round']

# Plot each data series in different cap dash styles
for i,x in enumerate(dash_capstyles):
plt.plot([n*(i+1) for n in y],lw=10,ls='--',dash_capstyle=x,label=x)

plt.legend(fontsize=16)
plt.show()

From the following figure, we can clearly see how blunt and round dashes give different impressions of sharpness and subtlety:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.194.55