【发布时间】:2018-07-11 11:03:45
【问题描述】:
下面是我尝试使用 Python 3.6.3 打印的数据框。在使用下面的代码更改颜色之前,我的图表打印完美。但是,现在图表打印时没有任何条形。
另外,我不知道如何使用下面的列表更改所有条形图颜色。我正在 Jupyter 中进行一个项目,并且图表打印得很好。唯一的问题是颜色仍未根据列表进行调整。只有橙色和绿色打印出来。
market_cap_usd market_cap_perc
id
bitcoin 1.862130e+11 33.481495
ethereum 1.141650e+11 20.527111
ripple 4.906157e+10 8.821376
bitcoin-cash 2.782094e+10 5.002265
cardano 1.522458e+10 2.737413
neo 1.041332e+10 1.872338
stellar 9.829044e+09 1.767283
litecoin 9.758786e+09 1.754651
eos 8.518116e+09 1.531575
nem 7.917498e+09 1.423583
# Colors for the bar plot
COLORS = ['orange', 'green', 'orange', 'cyan', 'cyan', 'blue', 'silver', 'orange', 'red', 'green']
# Plotting market_cap_usd as before but adding the colors and scaling the y-axis
ax = cap10.plot.bar(color=COLORS, title=TOP_CAP_TITLE, logy=True)
# Annotating the y axis with 'USD'
ax.set_ylabel('USD')
# Final touch! Removing the xlabel as it is not very informative
# ... YOUR CODE FOR TASK 5 ...
ax.set_xlabel('')
plt.show(ax)
【问题讨论】:
标签: python pandas matplotlib