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.
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 2015-04-09 18:31
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.
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.
self.colors[k]
? When I run the similar code it says NameError: name 'self' is not defined
- LWZ 2013-07-30 04:14
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')
markersize
to a larger value.markersize
can be a kwarg toplot()
, or you can abbreviate asms
. e.g.:..., markersize=20, ...
bernie 2012-04-04 19:33