MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / draw_sizebar

Function draw_sizebar

galleries/examples/misc/anchored_artists.py:51–65  ·  view source on GitHub ↗

Draw a horizontal bar with length of 0.1 in data coordinates, with a fixed label center-aligned underneath.

(ax)

Source from the content-addressed store, hash-verified

49
50
51def 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
68fig, ax = plt.subplots()

Callers 1

Calls 7

add_artistMethod · 0.95
AuxTransformBoxClass · 0.90
Line2DClass · 0.90
TextAreaClass · 0.90
VPackerClass · 0.90
AnchoredOffsetboxClass · 0.90
add_artistMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…