带有空标记的Matplotlib打印线

2024-05-14 18:37:22 发布

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

我以这种方式绘制了一些数据:

plt.plot(x, data['Coherence'], color='b', marker='.', linestyle='solid', mfc='none', mec='b')
plt.xlabel("Number of Topics")
plt.ylabel("Coherence score")
plt.legend("coherence_values", loc='best')
plt.show()

输出(正确)为: Text

这几乎是我想要的,但在标记后面,我仍然可以看到部分线条。 有办法得到这样的结果吗

enter image description here

谢谢大家!


Tags: 数据nonedataplot方式绘制pltmarker
1条回答
网友
1楼 · 发布于 2024-05-14 18:37:22

您可以将markerfacecolor参数设置为“白色”以获得所需的结果

例如:

import matplotlib.pyplot as plt
import numpy as np

plt.plot(np.random.randn(10), color='b', marker='.', linestyle='solid',  mfc='none', mec='b', markersize=24, markerfacecolor='white')

得出以下数字:

enter image description here

相关问题 更多 >

    热门问题