r""" Define how the two endpoints (caps) of an unclosed line are drawn. How to draw the start and end points of lines that represent a closed curve (i.e. that end in a `~.path.Path.CLOSEPOLY`) is controlled by the line's `JoinStyle`. For all other lines, how the start and end points
| 107 | |
| 108 | |
| 109 | class CapStyle(str, Enum): |
| 110 | r""" |
| 111 | Define how the two endpoints (caps) of an unclosed line are drawn. |
| 112 | |
| 113 | How to draw the start and end points of lines that represent a closed curve |
| 114 | (i.e. that end in a `~.path.Path.CLOSEPOLY`) is controlled by the line's |
| 115 | `JoinStyle`. For all other lines, how the start and end points are drawn is |
| 116 | controlled by the *CapStyle*. |
| 117 | |
| 118 | For a visual impression of each *CapStyle*, `view these docs online |
| 119 | <CapStyle>` or run `CapStyle.demo`. |
| 120 | |
| 121 | By default, `~.backend_bases.GraphicsContextBase` draws a stroked line as |
| 122 | squared off at its endpoints. |
| 123 | |
| 124 | **Supported values:** |
| 125 | |
| 126 | .. rst-class:: value-list |
| 127 | |
| 128 | 'butt' |
| 129 | the line is squared off at its endpoint. |
| 130 | 'projecting' |
| 131 | the line is squared off as in *butt*, but the filled in area |
| 132 | extends beyond the endpoint a distance of ``linewidth/2``. |
| 133 | 'round' |
| 134 | like *butt*, but a semicircular cap is added to the end of the |
| 135 | line, of radius ``linewidth/2``. |
| 136 | |
| 137 | .. plot:: |
| 138 | :alt: Demo of possible CapStyle's |
| 139 | |
| 140 | from matplotlib._enums import CapStyle |
| 141 | CapStyle.demo() |
| 142 | |
| 143 | """ |
| 144 | butt = "butt" |
| 145 | projecting = "projecting" |
| 146 | round = "round" |
| 147 | |
| 148 | @staticmethod |
| 149 | def demo(): |
| 150 | """Demonstrate how each CapStyle looks for a thick line segment.""" |
| 151 | import matplotlib.pyplot as plt |
| 152 | |
| 153 | fig = plt.figure(figsize=(4, 1.2)) |
| 154 | ax = fig.add_axes((0, 0, 1, 0.8)) |
| 155 | ax.set_title('Cap style') |
| 156 | |
| 157 | for x, style in enumerate(['butt', 'round', 'projecting']): |
| 158 | ax.text(x+0.25, 0.85, style, ha='center') |
| 159 | xx = [x, x+0.5] |
| 160 | yy = [0, 0] |
| 161 | ax.plot(xx, yy, lw=12, color='tab:blue', solid_capstyle=style) |
| 162 | ax.plot(xx, yy, lw=1, color='black') |
| 163 | ax.plot(xx, yy, 'o', color='tab:red', markersize=3) |
| 164 | |
| 165 | ax.set_ylim(-.5, 1.5) |
| 166 | ax.set_axis_off() |
no outgoing calls
no test coverage detected
searching dependent graphs…