1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.axes_grid1.anchored_artists import AnchoredDirectionArrows import matplotlib.font_manager as fm
fig, ax = plt.subplots() ax.imshow(np.random.random((10, 10)))
simple_arrow = AnchoredDirectionArrows(ax.transAxes, 'X', 'Y') ax.add_artist(simple_arrow)
high_contrast_part_1 = AnchoredDirectionArrows( ax.transAxes, '111', r'11$\overline{2}$', loc='upper right', arrow_props={'ec': 'w', 'fc': 'none', 'alpha': 1, 'lw': 2} ) ax.add_artist(high_contrast_part_1)
high_contrast_part_2 = AnchoredDirectionArrows( ax.transAxes, '111', r'11$\overline{2}$', loc='upper right', arrow_props={'ec': 'none', 'fc': 'k'}, text_props={'ec': 'w', 'fc': 'k', 'lw': 0.4} ) ax.add_artist(high_contrast_part_2)
fontprops = fm.FontProperties(family='serif')
roatated_arrow = AnchoredDirectionArrows( ax.transAxes, '30', '120', loc='center', color='w', angle=30, fontproperties=fontprops ) ax.add_artist(roatated_arrow)
a1 = AnchoredDirectionArrows( ax.transAxes, 'A', 'B', loc='lower center', length=-0.15, sep_x=0.03, sep_y=0.03, color='r' ) ax.add_artist(a1)
a2 = AnchoredDirectionArrows( ax.transAxes, 'A', ' B', loc='lower left', aspect_ratio=-1, sep_x=0.01, sep_y=-0.02, color='orange' ) ax.add_artist(a2)
a3 = AnchoredDirectionArrows( ax.transAxes, ' A', 'B', loc='lower right', length=-0.15, aspect_ratio=-1, sep_y=-0.1, sep_x=0.04, color='cyan' ) ax.add_artist(a3)
plt.show()
|