22
votes

I'm trying to make a scatter plot of some PCA data. I do some pretty typical code:

plt.plot(pca[:,0], pca[:,1], '.',ms=3,  markerfacecolor = self.colors[k],
            markeredgecolor = 'none')

I want it to show just the marker face color with no outline. The problem is that the markers disappear completely when markeredgecolor = 'none'. When I set markerfacecolor='none' or to a color and remove markeredgecolor, it works like expected.

I just updated matplotlib, numpy, etc. to the newest versions, running on Python 2.7.

Thanks for your help.

3
You might try setting the markersize to a larger value. markersize can be a kwarg to plot(), or you can abbreviate as ms. e.g.: ..., markersize=20, ... - mechanical_meat
For those trying to do this with matplotlib.errorbar using the markeredgecolor=None recommended below did not remove the black outlining the symbol. Instead markeredgecolor='none'did work (the symbols were not invisible). Not surprisingly, it seems the bug that led to this question has been fixed in the past 3 years. - Steven C. Howell

3 Answers

18
votes

I think this is a bug that was fixed a few months ago: https://github.com/matplotlib/matplotlib/pull/598

Regardless of how large you make the markers or if you use marker='o' instead of '.', they'll be invisible if you use markeredgecolor='none'.

As a workaround, you can just set the edge colors to the same as the face colors.

5
votes

In matplotlib 1.1

>> plt.plot(pca[:,0], pca[:,1], '.', ms=3, markerfacecolor=self.colors[k],
...          markeredgecolor=None)

works (note the None instead of 'none' for markeredgecolor).

Setting markeredgewidth=0.0 or markeredgecolor=self.colors[k] (as suggested by Joe Kington) should work, too.

5
votes

Try this:

x = np.array(np.random.rand(10))
y = np.array(np.random.rand(10))
c = np.arange(len(x))
plt.scatter(x,y, c=c, s=500, cmap = plt.cm.Paired, alpha = 0.5,linewidths=0)

Or, this is a good option too:

plt.scatter(x,y, c=c, s=500, cmap = plt.cm.Paired, alpha = 0.5,edgecolor='face')