【发布时间】:2019-04-15 19:24:55
【问题描述】:
我最近开始了 DataCamp 的 Python 统计思维(第 1 部分)课程,讲师提到在 Python 中构建绘图时,惯例通常是在构建绘图时将绘图对象分配给 NULL 运算符“_”,之前显示情节。
这真的是约定吗?我找不到太多的证据,我也想不出为什么它会成为惯例的理由。下面的代码 sn-p 取自课程示例并演示了我的意思。
# Plot all ECDFs on the same plot
_ = plt.plot(x_set, y_set, marker='.', linestyle='none')
_ = plt.plot(x_vers, y_vers, marker='.', linestyle='none')
_ = plt.plot(x_virg, y_virg, marker='.', linestyle='none')
# Annotate the plot
_ = plt.legend(('setosa', 'versicolor', 'virginica'), loc='lower right')
_ = plt.xlabel('petal length (cm)')
_ = plt.ylabel('ECDF')
# Display the plot
plt.show()
【问题讨论】:
标签: python matplotlib operators variable-assignment assignment-operator