我正在尝试绘制来自同一只熊猫df的多个密度图,但是要获得一个包含所有数据的图。关于如何为列表的每个元素分别绘制图的任何建议?
for i in List:
ax = df[i].plot(kind='density', colormap="Set2", label='')
plt.axvline(point_of_interest, linestyle='dashed', linewidth=2, color='r', label="Current Price")
plt.title(i)
ax.legend(loc='lower center', bbox_to_anchor=(0.5, -0.25), ncol=2)
谢谢!
答案 0 :(得分:0)
尝试
for i in List:
ax = df[i].plot(kind='density', colormap="Set2", label='')
plt.axvline(point_of_interest, linestyle='dashed', linewidth=2, color='r', label="Current Price")
plt.title(i)
ax.legend(loc='lower center', bbox_to_anchor=(0.5, -0.25), ncol=2)
plt.figure()
这将在循环中的每次迭代中产生一个新的数字