Python中的 Matplotlib.axes.Axes.semilogy()
Matplotlib是Python中的一个库,它是 NumPy 库的数值-数学扩展。Axes类包含大部分图形元素:Axis、Tick、Line2D、Text、Polygon 等,并设置坐标系。 Axes 的实例通过回调属性支持回调。
matplotlib.axes.Axes.semilogy()函数
matplotlib 库的轴模块中的Axes.semilogy()函数用于在 y 轴上绘制对数缩放的绘图。
Syntax:
Parameters: This method accept the following parameters that are described below:
- basey: This parameter is the base of the y logarithm and are optional with default value 10.
- subsy: This parameter is the sequence of location of the minor y ticks and is optional.
- nonposy: This parameter is a non-positive values in y that can be masked as invalid, or clipped to a very small positive number.
Returns: This returns the following:
- lines:This returns the list of Line2D objects representing the plotted data..
下面的示例说明了 matplotlib.axes 中的 matplotlib.axes.Axes.semilogy()函数:
示例 1:
Axes.semilogy(self, *args, **kwargs)
输出:
示例 2:
# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
test = np.arange(0.01, 30.0, 0.1)
# Create figure
fig, ax = plt.subplots()
# log x axis
ax.semilogy(test, np.exp(-test / 5.0))
ax.grid()
ax.set_title('matplotlib.axes.Axes.semilogy Example1')
plt.show()
输出: