MCPcopy
hub / github.com/matplotlib/matplotlib / demo

Method demo

lib/matplotlib/_enums.py:77–101  ·  view source on GitHub ↗

Demonstrate how each JoinStyle looks for various join angles.

()

Source from the content-addressed store, hash-verified

75
76 @staticmethod
77 def demo():
78 """Demonstrate how each JoinStyle looks for various join angles."""
79 import numpy as np
80 import matplotlib.pyplot as plt
81
82 def plot_angle(ax, x, y, angle, style):
83 phi = np.radians(angle)
84 xx = [x + .5, x, x + .5*np.cos(phi)]
85 yy = [y, y, y + .5*np.sin(phi)]
86 ax.plot(xx, yy, lw=12, color='tab:blue', solid_joinstyle=style)
87 ax.plot(xx, yy, lw=1, color='black')
88 ax.plot(xx[1], yy[1], 'o', color='tab:red', markersize=3)
89
90 fig, ax = plt.subplots(figsize=(5, 4), constrained_layout=True)
91 ax.set_title('Join style')
92 for x, style in enumerate(['miter', 'round', 'bevel']):
93 ax.text(x, 5, style)
94 for y, angle in enumerate([20, 45, 60, 90, 120]):
95 plot_angle(ax, x, y, angle, style)
96 if x == 0:
97 ax.text(-1.3, y, f'{angle} degrees')
98 ax.set_xlim(-1.5, 2.75)
99 ax.set_ylim(-.5, 5.5)
100 ax.set_axis_off()
101 fig.show()
102
103
104JoinStyle.input_description = "{" \

Callers

nothing calls this directly

Calls 8

plot_angleFunction · 0.85
subplotsMethod · 0.45
set_titleMethod · 0.45
textMethod · 0.45
set_xlimMethod · 0.45
set_ylimMethod · 0.45
set_axis_offMethod · 0.45
showMethod · 0.45

Tested by

no test coverage detected