温度梯度填充的matplotlib计算公式

时间:2021-05-14 12:27:23

标签: python numpy matplotlib

enter image description here

你好。我是 matplotlib 的新手,我需要制作一个热梯度来显示电压水平,如图所示。请告诉我如何使用 matplotlib 实现?到目前为止,我已经看过这样一个例子(下面的代码),但我不明白如何改变它。

import numpy as np
import matplotlib.pyplot as plt
import time

x = np.arange(0, np.pi, 0.01)
y = np.arange(0, np.pi, 0.01)
X, Y = np.meshgrid(x, y)
Z = np.cos(X) * np.sin(Y) * 10

fig, axs = plt.subplots()
cmap = plt.get_cmap('jet')
im2 = axs.imshow(Z, interpolation='nearest', cmap=cmap)
bounds = [-10.0, -8.0, -6.0, -4.0, -2.0, 0.0, 2.0, 4.0, 6.0, 8.0, 10.0]
fig.colorbar(im2, ax=axs, ticks=bounds, extend='both', extendfrac='auto')
fig.canvas.draw()
plt.show()

0 个答案:

没有答案