为什么我的python绘图代码在添加图例后运行得如此缓慢?

2024-10-01 04:53:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我想画一个熊猫的散点图,它运行良好。但在我添加了图例之后,它运行得非常慢,并且卡住了。有人能帮我吗

fcdp_data_100HZ[['Second','totCNTs']].plot.scatter(x="Second", y="totCNTs",color='royalblue',s=100,alpha=0.5, ax=axes[1])
axes[1].set_title("Counts")
axes[1].grid()
axes[1].set_ylim([1,100])
axes[1].set_yscale('log')
axes[1].set_ylabel("Counts")
axes[1].legend(['100HZ'])

fcdp_data_20HZ[['Second','totCNTs']].plot.scatter(x="Second", y="totCNTs",color='coral', s=100,alpha=0.5, ax=axes[1])
axes[1].set_title("Counts")
axes[1].grid()
axes[1].set_ylim([1,100])
axes[1].set_yscale('log')
axes[1].set_ylabel("Counts")
axes[1].legend(['20HZ'])

fcdp_data_1HZ[['Second','totCNTs']].plot.scatter(x="Second", y="totCNTs",color='darkslategrey',s=100,alpha=0.5, ax=axes[1])
axes[1].set_title("Counts")
axes[1].grid()
axes[1].set_ylim([1,100])
axes[1].set_yscale('log')
axes[1].set_ylabel("Counts")
axes[1].legend(['1HZ'])
plt.show()

Tags: alphadataplottitleaxgridcolorsecond