3

I have such code

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.markers as mks


plt.close('all')
N = 50
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = np.pi * (15 * np.random.rand(N))**2 # 0 to 15 point radiuses
mymkstyle = mks.MarkerStyle(marker=u'o', fillstyle=u'full')
plt.scatter(x, y,color = 'k',s = 100, marker = mymkstyle )
plt.show()

I try to create some custom MarkerStyle and use it for scatter functions, but this script failed in the scatter function.

Any ideas? Thanks. I'm using python 2.7.6 and mathplotlib 1.3.1 under WinXP.

ollydbg23
  • 1,124
  • 1
  • 12
  • 38

1 Answers1

2

Although the documentation states that MarkerStyle is the type to pass for marker=, this doesn't seem to be implemented correctly. This bug has been reported on GitHub.

plt.plot(x, y, marker='o', markersize=100, fillstyle='bottom')

seems to do pretty much what you're looking for; of course, this doesn't let you treat marker styles as objects.

Alex Szatmary
  • 3,431
  • 3
  • 21
  • 30
  • 1
    Hi, thanks. I use the patch mentioned [MarkerStyle Instance not Accepted for scatter · Issue #3895 · matplotlib/matplotlib](https://github.com/matplotlib/matplotlib/issues/3895), and it did solve the failure, but I still see the scatter function does not works well. (See the comment in that report there). Any way, I think using `plt.plot` function are good alternatives until bug 3895 is totally solved. – ollydbg23 Dec 17 '14 at 00:13