Matplotlib是Python中的一個庫,它是數字的-NumPy庫的數學擴展。軸類包含大多數圖形元素:Axis,Tick,Line2D,Text,Polygon等,並設置坐標係。 Axes實例通過callbacks屬性支持回調。
matplotlib.axes.Axes.loglog()函數
matplotlib庫的axiss模塊中的Axes.errorbar()函數用於繪製在x和y軸上均具有對數比例的圖。
用法:
Axes.loglog(self, *args, **kwargs)
參數:此方法接受以下描述的參數:
- basex, basey:這些參數是x /y對數的底數,並且是可選參數,默認值為10。
- subsx, subsy:這些參數是次要x /y刻度的位置順序,並且是可選的。
- nonposx, nonposy:這些參數是x或y中的非正值,可以將其掩蓋為無效值,或裁剪為非常小的正數。
返回值:這將返回以下內容:
- lines:這將返回代表繪製數據的Line2D對象的列表。
以下示例說明了matplotlib.axes中的matplotlib.axes.Axes.loglog()函數:
示例1:
# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
t = np.arange(0.01, 20.0, 0.01)
# Create figure
fig, ax = plt.subplots()
# log x and y axis
ax.loglog(t, 20 * np.exp(-t / 10.0), basex = 2)
ax.set_title('matplotlib.axes.Axes.loglog Example2')
plt.show()
輸出:
示例2:
# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots(constrained_layout = True)
x = np.arange(0.02, 1, 0.02)
np.random.seed(19680801)
y = np.random.randn(len(x)) ** 2
ax.loglog(x, y)
ax.set_xlabel('f [Hz]')
ax.set_ylabel('PSD')
ax.set_title('Random spectrum')
def forward(x):
return 1 / x
def inverse(x):
return 1 / x
ax.set_title('matplotlib.axes.Axes.loglog Example2')
plt.show()
輸出:
相關用法
注:本文由純淨天空篩選整理自SHUBHAMSINGH10大神的英文原創作品 matplotlib.axes.Axes.loglog() in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。