我正在为每个第三个变量的每个变量对构建一组图形,例如:
pressures = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0]
thicknesses = [0.5, 1.0, 1.5, 2.0]
velocities = [600.0, 700.0]
for velocity in velocities:
for thickness in thicknesses:
fig, ax = plt.subplots(1, 1)
cmap = plt.get_cmap('rainbow')
for pressure in pressures:
colors = iter(cmap(pressure/len(pressures)))
try:
ax.plot(x, y, label='{} mbar'.format(pressure), color=colors) #where (x, y) are variables decided earlier in the try loop
except TypeError:
continue
ax.plot()
ax.legend()
plt.show()
这将使用我想要的数据构建一个图形,但是我无法使颜色图起作用。我试图让它在厚度/速度对的每次迭代中为每个压力显示相同的颜色。