Draw a horizontal bar with length of 0.1 in data coordinates, with a fixed label center-aligned underneath.
(ax)
| 49 | |
| 50 | |
| 51 | def draw_sizebar(ax): |
| 52 | """ |
| 53 | Draw a horizontal bar with length of 0.1 in data coordinates, |
| 54 | with a fixed label center-aligned underneath. |
| 55 | """ |
| 56 | size = 0.1 |
| 57 | text = r"1$^{\prime}$" |
| 58 | sizebar = AuxTransformBox(ax.transData) |
| 59 | sizebar.add_artist(Line2D([0, size], [0, 0], color="black")) |
| 60 | text = TextArea(text) |
| 61 | packer = VPacker( |
| 62 | children=[sizebar, text], align="center", sep=5) # separation in points. |
| 63 | ax.add_artist(AnchoredOffsetbox( |
| 64 | child=packer, loc="lower center", frameon=False, |
| 65 | pad=0.1, borderpad=0.5)) # paddings relative to the legend fontsize. |
| 66 | |
| 67 | |
| 68 | fig, ax = plt.subplots() |
no test coverage detected
searching dependent graphs…