y轴将会以指数方式递增. 基于半对数坐标系表示上述曲线可以更好的观察底部数据细节.
# plot改为semilogy, 坐标系将会改为半对数坐标系
mp.semilogy()
"""
半对数坐标系
"""
import matplotlib.pyplot as mp
mp.figure('Grid Line', facecolor='lightgray')
mp.subplot(1, 2, 1)
mp.title('Grid Line', fontsize=16)
mp.xlabel('X', fontsize=12)
mp.ylabel('Y', fontsize=12)
mp.tick_params(labelsize=10)
# 绘制刻度网格线
ax = mp.gca()
ax.xaxis.set_major_locator(mp.MultipleLocator())
ax.xaxis.set_minor_locator(
mp.MultipleLocator(0.1))
ax.yaxis.set_major_locator(
mp.MultipleLocator(250))
ax.yaxis.set_minor_locator(
mp.MultipleLocator(50))
ax.grid(which='major', axis='both',
linewidth=0.75, linestyle='-',
color='orange')
ax.grid(which='minor', axis='both',
linewidth=0.25, linestyle='-',
color='orange')
y = [1, 10, 100, 1000, 100, 10, 1]
mp.plot(y, color='dodgerblue')
mp.subplot(1, 2, 2)
mp.title('Semilogy', fontsize=16)
mp.xlabel('X', fontsize=12)
mp.ylabel('Y', fontsize=12)
mp.tick_params(labelsize=10)
# 绘制刻度网格线
ax = mp.gca()
ax.xaxis.set_major_locator(mp.MultipleLocator())
ax.xaxis.set_minor_locator(
mp.MultipleLocator(0.1))
ax.yaxis.set_major_locator(
mp.MultipleLocator(250))
ax.yaxis.set_minor_locator(
mp.MultipleLocator(50))
ax.grid(which='major', axis='both',
linewidth=0.75, linestyle='-',
color='orange')
ax.grid(which='minor', axis='both',
linewidth=0.25, linestyle='-',
color='orange')
y = [1, 10, 100, 1000, 100, 10, 1]
mp.semilogy(y, color='dodgerblue')
mp.show()