Skip to content

The markers are not hollow when I use ax.scatter() and set markers.MarkerStyle()'s fillstyle to 'none'. My usage is wrong? #17527

Closed

Description

@NoahFeng

I want to set markers hollow. So I make a costomed markers.MarkerStyle and set the paramter fillstyle='none'. But I don't get what I want.

Code for reproduction

from matplotlib import pyplot as plt
from matplotlib import markers
import numpy as np
xy = np.random.rand(10, 2)
fig, ax = plt.subplots()
style = markers.MarkerStyle(marker='o', fillstyle='none')
ax.scatter(xy[:, 0], xy[:, 1], marker=style)
plt.show()

Actual outcome

Snipaste_2020-05-28_18-17-01

Expected outcome
This is what I want.
Snipaste_2020-05-28_18-20-13

When I check out the source code about the matplotlib.markers.MarkerStyle, I find:
Snipaste_2020-05-28_18-27-40
It seems that it doesn't process fillstyle='none'.
I don't know why. Maybe my usage is wrong. Could anyone help me?

Matplotlib version

  • Operating system: Win10
  • Matplotlib version: 3.1.1
  • Python version: 3.6.6

Activity

  1. timhoffm commented on May 31, 2020

    @timhoffm
    Member

    This is indeed a bug - fillstyle='none' was not respected by scatter().

    Workarounds

    • If you don't need specific scatter() properties (like varying color or size) the simplest appoach is using plot():

      ax.plot(xy[:, 0], xy[:, 1], 'o', markerfacecolor='none')
      
    • For scatter() you can directly define the properties as keyword arguments:

      ax.scatter(xy[:, 0], xy[:, 1], marker='o', facecolors='none', edgecolors='C0')
      
  2. added this to the v3.3.0 milestone on Jun 4, 2020
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