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 with Python Create x_data and y_data(sin(x_data)), using numpy. Plot curve using x_data and y_data, with marker style and marker size. By changing the alpha, we can make it transparent to opaque. To get the essence of transparency (keeping alhpa value lesser), we can make grid lines, to see through.
Marker size is scaled by s and marker color is mapped to c . size in points^2. Default is rcParams['lines. markersize'] ** 2 .
It is currently not possible to supply a list of markers to the marker argument of scatter . Save this answer.
All of the line properties can be controlled by keyword arguments. For example, you can set the color, marker, linestyle, and markercolor with: plot(x, y, color='green', linestyle='dashed', marker='o', markerfacecolor='blue', markersize=12).
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.
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')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With