本文簡要介紹 python 語言中mpl_toolkits.axes_grid1.anchored_artists.AnchoredSizeBar
的用法。
-
繪製一個水平比例尺,其下方帶有 center-aligned 標簽。
- 參數:
- transform
Transform
-
正在使用的坐標係的變換對象,即
matplotlib.axes.Axes.transData
。 - size 浮點數
-
尺寸條的水平長度,以
transform
的坐標給出。 - label str
-
要顯示的標簽。
- loc str
-
尺寸欄的位置。有效位置為'upper left'、'upper center'、'upper right'、'center left'、'center'、'center right'、'lower left'、'lower center'、'lower right'。為了向後兼容,也接受數值。詳情請參見
Legend
的參數loc
。 - pad 浮點數,默認值:0.1
-
標簽和大小欄周圍的填充,以字體大小的一小部分。
- borderpad 浮點數,默認值:0.1
-
邊框填充,以字體大小的分數表示。
- sep 浮點數,默認值:2
-
標簽和尺寸欄之間的分隔,以磅為單位。
- frameon 布爾值,默認值:真
-
如果為 True,請在水平條和標簽周圍繪製一個框。
- size_vertical 浮點數,默認值:0
-
尺寸條的垂直長度,以
transform
的坐標給出。 - color str,默認值:'black'
-
尺寸欄和標簽的顏色。
- label_top 布爾值,默認值:假
-
如果為 True,則標簽將位於尺寸欄上方。
- fontproperties
FontProperties
,可選 -
標簽文本的字體屬性。
- fill_bar 布爾型,可選
-
如果為 True 並且
size_vertical
非零,則尺寸欄將填充尺寸欄指定的顏色。如果size_vertical
大於零,則默認為 True,否則默認為 False。 - **kwargs
-
關鍵字參數轉發到
AnchoredOffsetbox
。
- transform
注意
如果
prop
作為關鍵字參數傳遞,但fontproperties
不是,則prop
被假定為預期的fontproperties
。不支持同時使用prop
和fontproperties
。例子
>>> import matplotlib.pyplot as plt >>> import numpy as np >>> from mpl_toolkits.axes_grid1.anchored_artists import ( ... AnchoredSizeBar) >>> fig, ax = plt.subplots() >>> ax.imshow(np.random.random((10, 10))) >>> bar = AnchoredSizeBar(ax.transData, 3, '3 data units', 4) >>> ax.add_artist(bar) >>> fig.show()
使用所有可選參數
>>> import matplotlib.font_manager as fm >>> fontprops = fm.FontProperties(size=14, family='monospace') >>> bar = AnchoredSizeBar(ax.transData, 3, '3 units', 4, pad=0.5, ... sep=5, borderpad=0.5, frameon=False, ... size_vertical=0.5, color='white', ... fontproperties=fontprops)
- 屬性:
- size_bar
AuxTransformBox
-
尺寸欄的容器。
- txt_label
TextArea
-
尺寸欄標簽的容器。
- size_bar
用法
class mpl_toolkits.axes_grid1.anchored_artists.AnchoredSizeBar(transform, size, label, loc, pad=0.1, borderpad=0.1, sep=2, frameon=True, size_vertical=0, color='black', label_top=False, fontproperties=None, fill_bar=None, **kwargs)
相關用法
- Python matplotlib AnchoredDrawingArea用法及代碼示例
- Python matplotlib AnchoredAuxTransformBox用法及代碼示例
- Python matplotlib AnchoredDirectionArrows用法及代碼示例
- Python matplotlib Axes.get_legend_handles_labels用法及代碼示例
- Python matplotlib AbstractMovieWriter用法及代碼示例
- Python matplotlib Axes.hist用法及代碼示例
- Python matplotlib Axes.step用法及代碼示例
- Python matplotlib Axes.contour用法及代碼示例
- Python matplotlib Axes.plot用法及代碼示例
- Python matplotlib Axes.semilogx用法及代碼示例
- Python matplotlib Axes.semilogy用法及代碼示例
- Python matplotlib Axes.inset_axes用法及代碼示例
- Python matplotlib Axes.axis用法及代碼示例
- Python matplotlib AutoDateFormatter用法及代碼示例
- Python matplotlib Axes.barbs用法及代碼示例
- Python matplotlib Axes.tripcolor用法及代碼示例
- Python matplotlib AsteriskPolygonCollection用法及代碼示例
- Python matplotlib Affine2D.set_matrix用法及代碼示例
- Python matplotlib AxisArtist.toggle用法及代碼示例
- Python matplotlib Axis.get_tick_params用法及代碼示例
- Python matplotlib Axes.set_prop_cycle用法及代碼示例
- Python matplotlib ArrowStyle用法及代碼示例
- Python matplotlib Axes.axline用法及代碼示例
- Python matplotlib Axes.tick_params用法及代碼示例
- Python matplotlib Axes.axvspan用法及代碼示例
注:本文由純淨天空篩選整理自skytowner.com大神的英文原創作品 mpl_toolkits.axes_grid1.anchored_artists.AnchoredSizeBar。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。