Skip to content

MarkerStyle Instance not Accepted for scatter #3895

Closed

Description

@rosenbrockc

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 https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes/_axes.py#L3647 with the following to fix it:

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

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

Activity

  1. tacaswell commented on Dec 7, 2014

    @tacaswell
    Member

    Can you put in a pull request with that change (plus a test)?

  2. added this to the v1.4.x milestone on Dec 7, 2014
  3. tacaswell commented on Dec 7, 2014

    @tacaswell
    Member

    Can you also update the docs on scatter to mention that marker takes strings?

  4. asmwarrior commented on Dec 17, 2014

    @asmwarrior

    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
    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()
    

    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.

  5. modified the milestones: v1.4.x, on Feb 7, 2015
  6. tacaswell commented on Feb 19, 2015

    @tacaswell
    Member

    Closed by 86e5e65

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions