擅长:python、mysql、java
<p>我想alpha只是一个使用不同深浅蓝色的变通方法?在这种情况下,可以使用<code>Blues</code>颜色映射。<br/>
可以使用<code>LineCollection</code>绘制几条线。你知道吗</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
x1 =[0, 19, 39, 46, 60, 79]
x2 = [19, 39, 46, 60, 79, 90]
alpha_list = [-0.8402, -0.6652, 0.0, -0.5106, -0.8074, 0.0]
verts = np.dstack((np.c_[x1, x2], np.zeros((len(x1), 2))))
fig, ax = plt.subplots()
lc = LineCollection(verts, linewidth=40, cmap="Blues_r", array=np.array(alpha_list))
ax.add_collection(lc)
ax.autoscale()
ax.set_ylim(-1,1)
fig.colorbar(lc)
plt.show()
</code></pre>
<p><a href="https://i.stack.imgur.com/pnL0P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pnL0P.png" alt="enter image description here"/></a></p>