注意
跳转至页面底部 下载完整示例代码。
3D 上的坐标轴缩放(对数、对称对数等)#
演示如何在 3D 轴上使用非线性缩放(如对数缩放)。
3D 轴支持与 2D 图形相同的轴缩放方式:'linear'(线性)、'log'(对数)、'symlog'(对称对数)、'logit'(Logit)、'asinh'(反双曲正弦)以及自定义的 'function'(函数)缩放。此示例展示了缩放方式的混合使用:X 轴为线性,Y 轴为对数,Z 轴为对称对数。
有关内置缩放方式的完整列表,请参阅 matplotlib.scale。有关缩放变换的概述,请参阅 缩放概述。
import matplotlib.pyplot as plt
import numpy as np
# A sine chirp with increasing frequency and amplitude
x = np.linspace(0, 1, 400) # time
y = 10 ** (2 * x) # frequency, growing exponentially from 1 to 100 Hz
phase = 2 * np.pi * (10 ** (2 * x) - 1) / (2 * np.log(10))
z = np.sin(phase) * x **2 * 10 # amplitude, growing quadratically
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
ax.plot(x, y, z)
ax.set_xlabel('Time (linear)')
ax.set_ylabel('Frequency, Hz (log)')
ax.set_zlabel('Amplitude (symlog)')
ax.set_yscale('log')
ax.set_zscale('symlog')
plt.show()

参考
本示例展示了以下函数、方法、类和模块的使用