问题描述
所以我试着用一个最小的例子来说明错误是如何抛出的,但令人困惑的是这个最小的例子实际上是有效的
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
color_list = [(1.0,0),(1.0,(0,1.0,1.0),0)]
for idx in range(0,20):
ax.plot([0,10],[10,idx],color=color_list[idx])
在这里,我将 RGB 元组从 color_list
传递到绘图,并且它起作用了!
但是当我尝试使用下面的代码将其作为更复杂的一系列绘图的一部分时,我不断收到 ValueError: RGBA values should be within 0-1 range
alpha = 1.0
col = 0
for g,h in zip(G,H):
bin_count = 80
G_hist = np.histogram(g,bin_count)
G_hist_bin = G_hist[1][-len(G_hist[0]):]
bin_count = int(1.0 + 3.322 * np.log2(len(h)))
M_hist = np.histogram(h,bin_count)
M_hist_bin = M_hist[1][-len(M_hist[0]):]
ax_1.plot(G_hist_bin,G_hist[0],color = color_list[col],lw = 1.0,alpha = alpha)
ax_2.plot(M_hist_bin,M_hist[0],alpha = alpha)
print(col,bin_count)
col += 1
alpha -= 0.1
那么为什么这在第一个示例中有效,而在第二个示例中无效?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)