这是我的密码:
import numpy as np
import matplotlib.dates as mdates
fig, ax = plt.subplots(figsize = (10,10))
dateList = []
countries = []
casesList = []
colors = []
for e in sorted_date:
countries.append(e[0])
dateList.append(e[1][0])
casesList.append(e[1][1])
# plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%m/%d/%Y'))
for country, date, case in zip(countries, dateList, casesList):
ax.scatter(date, case, c = np.random.rand(3,), edgecolors='none', label=country )
plt.legend(loc=1)
plt.show()
我的散点图有效,但 我一直收到颜色RGB或RGBA的错误消息,如下所示:
'c' argument looks like a single numeric RGB or RGBA sequence, which should be avoided as value-mapping will have precedence in case its length matches with 'x' & 'y'. Please use a 2-D array with a single row if you really want to specify the same RGB or RGBA value for all points.
我认为我随机化的颜色有问题,但不确定该怎么解决
您需要完全按照错误建议执行操作:为RGB阵列使用具有单行的2D阵列:
您可以将RGB元组转换为十六进制字符串as showb here:
相关问题 更多 >
编程相关推荐