Home > Net >  What is the length of the line cap in data units?
What is the length of the line cap in data units?

Time:11-10

When plotting a line using matplotlib, I used solid_capstyle="round". I see that the line extended beyond the assigned length. That is fine for what I want to do. But could I possibly know by how much the line is extended?

Essentially I would like to know the length of the cap.

Demo code:

from matplotlib import pyplot as plt

ax=plt.subplot()
ax.plot([0, 100], [15, 15], linewidth=50, linestyle="-", c="red",
         solid_capstyle="round")
ax.axvline(x=100, c="black")
ax.set_xlim(0, 125)
ax.set_ylim(0, 30)

enter image description here

In this example I want to know the length of the cap in terms of the data units. Visually it looks like 9 units (i.e. line extends upto x=109), but I would like to calculate that computationally.

CodePudding user response:

The showing cap-radius in data coordinates

  • Related