简体   繁体   中英

Matplotlib plot line with empty markers

I'm plotting some data in this way:

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()

And the output (correct) is:文本

That is almost what I would like, but behind the markers, I can still see part of the line. There is a way to get a result like this?

在此处输入图片说明

Thank you!

You can set the markerfacecolor parameter to "white" to obtain the desired result.

For instance:

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')

Yields the following figure:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM