MarkerStyle Instance not Accepted for scatter

The docstring for scatter says that the marker keyword argument will accept a matplotlib.markers.MarkerStyle instance. However, when I pass one in, it breaks when trying to initialize a new MarkerStyle instance using an existing one. We could easily replace with the following to fix it:

        if not isinstance(marker, mmarkers.MarkerStyle):
            marker_obj = mmarkers.MarkerStyle(marker)
            marker_obj = marker

or we could just fix the constructor for MarkerStyle to be smarter (a better option).

Author: Fantashit

1 thought on “MarkerStyle Instance not Accepted for scatter

  1. Hello, the patch mentioned by rosenbrockc did solve the failure of my test code:

    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib.markers as mks
    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 )

    But if I change the fillstyle to u'none', I still get all the circle filled with black colors, not a black ring. Fillstyle works OK with u'left', u'right', u'bottom', u'top' and u'full'.

    PS: I was asked this question in Stackoverflow: matplotlib, why custom marker style is not allowed in scatter functions, and someone pointed me here.

Comments are closed.