|
6 | 6 |
|
7 | 7 | The following hatching patterns are available, shown here at level 2 density: |
8 | 8 |
|
9 | | -.. plot:: |
| 9 | +.. plot:: _embedded_plots/hatch_classes.py |
10 | 10 | :include-source: false |
11 | | - :show-source-link: false |
12 | | - :plot_formats: png |
13 | | - :align: center |
14 | | - :alt: 8 squares, each showing the pattern corresponding to the hatch symbol: |
15 | | - symbol '/' makes right leaning diagonals, '\\' makes left leaning diagonals, |
16 | | - '|' makes vertical lines, '-' makes horizontal lines, |
17 | | - '+' makes a grid, 'X' makes a grid rotated 90 degrees, |
18 | | - 'o' makes small unfilled circles, 'O' makes large unfilled circles, |
19 | | - '.' makes small filled circles, and '*' makes a start with 5 points |
20 | | -
|
21 | | - from matplotlib.patches import Rectangle |
22 | | - fig, ax = plt.subplots() |
23 | | -
|
24 | | - pattern_to_class = { |
25 | | - '/': 'NorthEastHatch', |
26 | | - '\\': 'SouthEastHatch', |
27 | | - '|': 'VerticalHatch', |
28 | | - '-': 'HorizontalHatch', |
29 | | - '+': 'VerticalHatch + HorizontalHatch', |
30 | | - 'x': 'NorthEastHatch + SouthEastHatch', |
31 | | - 'o': 'SmallCircles', |
32 | | - 'O': 'LargeCircles', |
33 | | - '.': 'SmallFilledCircles', |
34 | | - '*': 'Stars', |
35 | | - } |
36 | | -
|
37 | | - for i, (hatch, classes) in enumerate(pattern_to_class.items()): |
38 | | - r = Rectangle((0.1, i+0.5), 0.8, 0.8, fill=False, hatch=hatch*2) |
39 | | - ax.add_patch(r) |
40 | | - h = ax.annotate(f"'{hatch}'", xy=(1.2, .5), xycoords=r, |
41 | | - family='monospace', va='center', ha='left') |
42 | | - ax.annotate(pattern_to_class[hatch], xy=(1.5, .5), xycoords=h, |
43 | | - family='monospace', va='center', ha='left', color='tab:blue') |
44 | | -
|
45 | | - ax.set(xlim=(0, 5), ylim=(0, i+1.5), yinverted=True) |
46 | | - ax.set_axis_off() |
| 11 | + :alt: 8 squares, each showing the pattern corresponding to the hatch symbol: symbol '/' makes right leaning diagonals, '\\' makes left leaning diagonals, '|' makes vertical lines, '-' makes horizontal lines, '+' makes a grid, 'X' makes a grid rotated 90 degrees, 'o' makes small unfilled circles, 'O' makes large unfilled circles, '.' makes small filled circles, and '*' makes a start with 5 points |
47 | 12 |
|
48 | 13 | """ |
49 | 14 |
|
|
0 commit comments