0
我创建了一个包含股票信息的数据框。当我去创建一个散点图并注释标签时,并不是所有的标签都包含在内。我只得到50个左右的3个标签。我无法弄清楚为什么它没有绘制所有标签。.annotate()不绘制所有标签
我的表:
Dividend ExpenseRatio Net_Assets PriceEarnings PriceSales
Ticker
FHLC 0.0128 0.08 6.056 22.95 1.78
ONEQ 0.0083 0.21 6.284 20.24 2.26
FTEC 0.0143 0.08 3.909 20.83 2.73
FDIS 0.0144 0.08 2.227 20.17 1.36
FENY 0.0262 0.08 4.386 25.97 1.34
我的绘制代码:
for ticker,row in df.iterrows():
plt.scatter(row['PriceSales'], row['PriceEarnings'], c = np.random.rand(3,1), s = 300)
for i, txt in enumerate(ticker):
plt.annotate(df.index[i-1], (df.PriceSales[i-1], df.PriceEarnings[i-1]))
plt.xlabel('PriceSales')
plt.ylabel('PriceEarnings')
plt.show()
我的图形图像:这里
把它放置在循环工人。不能相信我没有想到,但感谢解决方案! – Evy555