Skip to content

[ENH]: Fillstyle or just empty symbols in scatter #32012

Description

@stephtdouglas

Problem

I would like to be able to easily create open symbols with scatter that also have dynamically colored edges (e.g., with the c argument set to an array). Open symbols are important because I want to be able to see through one marker if it overlaps one below it, which isn't possible if you just overplot smaller white symbols onto colored markers.

Every option I can find will only produce open symbols which all have the same color edge, including this option:

This is achievable in scatter by plt.scatter(x, y, marker=MarkerStyle('o', fillstyle='none')).

Originally posted by @timhoffm in #20360

This produces black open circles in my code, instead of dynamically colored circles.

Here is a MWE that I've tested on Matplotlib 3.10.0 and 3.11.0

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.markers import MarkerStyle

rng = np.random.default_rng()

x = rng.normal(size=100)
y = rng.normal(size=100)
z = rng.uniform(size=100)

# Produces a dynamically colored scatter plot with solid circles, as expected
plt.scatter(x,y,c=z)

# Should produce a dynamically colored scatter plot with open circles, but doesn't
plt.scatter(x,y,c=z,marker=MarkerStyle('o', fillstyle='none'),cmap="viridis",vmin=0,vmax=1)

The last command produces the warning

/tmp/ipykernel_2642/88283468.py:2: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap', 'vmin', 'vmax' will be ignored

even though I did specify data for colormapping with 'c'. And it generates this image
Image

Layering points ends up looking sloppy, and doesn't preserve the "see-through" nature of open symbols

plt.scatter(x,y,c=z)
plt.scatter(x,y,c="w",s=9,)
Image

I created a new request instead of adding to [#20360] because I don't need a shortcut to do this, I just need the capability. Thank you for considering this request

Proposed solution

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions