【发布时间】:2014-02-13 22:44:42
【问题描述】:
我想将一系列点放在散点图上。每一点都取决于我对它的关心程度。我希望散点图上的点根据我对它的关心程度设置不透明度。
这是我目前的尝试,失败了
import pandas as pd
import matplotlib.pyplot as plt
x = pd.Series([0, .2, .4, .6, .8, 1])
y = pd.Series([0, .2, .4, .6, .8, 1])
weights = pd.Series([0, .2, .4, .6, .8, 1])
# this is me trying to create RGBA tuples from the weights
colors = weights.apply(lambda x: (0,0,1,x))
plt.scatter(x, y, c=colors)
plt.show()
plt.scatter 行失败并出现异常
AttributeError: 'tuple' 对象没有属性 'view'
【问题讨论】:
-
尝试将您的 pandas 对象 (
colors) 转换为列表或 ndarray。 -
请包含完整的回溯。
标签: python matplotlib pandas