MARCO LAGALLA
MARCO LAGALLA

Reputation: 257

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: Text

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?

enter image description here

Thank you!

Upvotes: 5

Views: 10292

Answers (2)

Viking Strong
Viking Strong

Reputation: 11

Here is a shorter example:

import matplotlib.pyplot as plt
import numpy as np

plt.plot(np.random.randn(10), 'b', marker = 'o', ms = 10, mfc = 'w')

Upvotes: 1

Sheldon
Sheldon

Reputation: 4633

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', markersize=24, markerfacecolor='white')

Yields the following figure:

enter image description here

Upvotes: 11

Related Questions