本文簡要介紹 python 語言中 matplotlib.axes.Axes.axline 的用法。
-
添加一條無限長的直線。
這條線可以由兩個點
xy1和xy2定義,也可以由一個點xy1和slope定義。無論 x 和 y 比例如何,這都會在“屏幕”上繪製一條直線,因此也適用於在半對數圖中繪製指數衰減,在對數圖中繪製冪律等。但是,
slope隻能與線性標尺;它對所有其他尺度沒有明確的含義,因此行為是未定義的。請使用點xy1,xy2為非線性刻度指定線。transform關鍵字參數僅適用於點xy1,xy2。slope(如果給定)始終位於數據坐標中。這可以用於例如ax.transAxes用於繪製具有固定斜率的網格線。- 參數:
- xy1, xy2 (浮點數,浮點數)
-
線要通過的點。必須給出
xy2或slope。 - slope 浮點數,可選
-
線的斜率。必須給出
xy2或slope。
- 返回:
- 其他參數:
- **kwargs
-
有效的 kwarg 是
Line2D屬性屬性
說明
一個過濾器函數,它接受一個 (m, n, 3) 浮點數組和一個 dpi 值,並返回一個 (m, n, 3) 數組和距圖像左下角的兩個偏移量
標量或無
bool
antialiased或 aabool
BboxBase或無bool
補丁或(路徑,變換)或無
color或 ccolor
CapStyle或 {'butt', 'projecting', 'round'}JoinStyle或 {'miter', 'round', 'bevel'}浮點數序列(以點為單位的開/關墨水)或(無,無)
(2, N) 數組或兩個一維數組
drawstyle或 ds{'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'},默認:'default'
{'full', 'left', 'right', 'bottom', 'top', 'none'}
顏色或無
str
bool
object
linestyle或 ls{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
linewidth或 lwfloat
標記樣式字符串,
Path或MarkerStylemarkeredgecolor或機械color
markeredgewidth或喵喵float
markerfacecolor或 mfccolor
markerfacecoloralt或 mfcaltcolor
markersize或毫秒float
None 或 int 或 (int, int) 或 slice 或 list[int] 或 float 或 (float, float) 或 list[bool]
bool
浮點數或可調用[[藝術家,事件],元組[布爾,字典]]
float
bool
(比例:浮點數,長度:浮點數,隨機性:浮點數)
布爾或無
CapStyle或 {'butt', 'projecting', 'round'}JoinStyle或 {'miter', 'round', 'bevel'}unknown
str
bool
一維數組
一維數組
float
例子
畫一條穿過 (0, 0) 和 (1, 1) 的粗紅線:
>>> axline((0, 0), (1, 1), linewidth=4, color='r')
用法
Axes.axline(xy1, xy2=None, *, slope=None, **kwargs)
相關用法
- Python matplotlib Axes.axis用法及代碼示例
- Python matplotlib Axes.axvspan用法及代碼示例
- Python matplotlib Axes.arrow用法及代碼示例
- Python matplotlib Axes.get_legend_handles_labels用法及代碼示例
- 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.barbs用法及代碼示例
- Python matplotlib Axes.tripcolor用法及代碼示例
- Python matplotlib Axes.set_prop_cycle用法及代碼示例
- Python matplotlib Axes.tick_params用法及代碼示例
- Python matplotlib Axes.contourf用法及代碼示例
- Python matplotlib Axes.tricontourf用法及代碼示例
- Python matplotlib Axes.locator_params用法及代碼示例
- Python matplotlib Axes.set_ylim用法及代碼示例
- Python matplotlib Axes.loglog用法及代碼示例
- Python matplotlib Axes.text用法及代碼示例
- Python matplotlib Axes.boxplot用法及代碼示例
- Python matplotlib Axes.triplot用法及代碼示例
- Python matplotlib Axes.tricontour用法及代碼示例
- Python matplotlib Axes.set_xlim用法及代碼示例
注:本文由純淨天空篩選整理自skytowner.com大神的英文原創作品 matplotlib.axes.Axes.axline。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
