0

I'm looking for a way to change the default edge color for matplotlib scatter plots. Typically, things like that would be set through rcParams, and my understanding is that I should set patch.edgecolor. However, that doesn't seem to work. Here is an example:

import numpy as np
from matplotlib import pyplot as plt

x = np.random.randn(50)
y = np.random.randn(50)

with plt.rc_context({'patch.edgecolor': 'white'}):
    plt.subplot(121)
    plt.scatter(x, y)

plt.subplot(122)
plt.scatter(x, y, edgecolors='white')

In the result, I would like to have both subplots look the same, but instead they look like this: What I want to see Note that I don't want to change the code within the with statement, but instead configure matplotlib such that it uses white edges as a fallback if I don't specify anything else. Confusingly, the documentation uses a default argument edgecolors=None in the function signature, but states that the default value for edgecolors is 'face'. How can I change this behaviour?

1
  • As of now there seems to be no such possibility. Read the comments on this. Currently the attributes for markers which you can set by default are plt.rcParams["lines.markeredgewidth"] = 2, plt.rcParams["lines.markersize"] = 10, and plt.rcParams["scatter.marker"] = 'o' Commented Apr 22, 2019 at 21:43

1 Answer 1

1

The rc parameter you're looking for is called

'scatter.edgecolors'

E.g. plt.rcParams['scatter.edgecolors'] = "white" or
with plt.rc_context({'scatter.edgecolors': 'white'}):.

This is a new feature introduced in #12992 and available from matplotlib 3.1 onwards, which will be released very soon. As of today, you can install the release candidate via pip install --pre --upgrade matplotlib to get this feature.

Sign up to request clarification or add additional context in comments.

2 Comments

Is that documented anywhere else than in the PR?
Well, since it's not yet officially released, it's only in the devdocs, where it says about edgecolors Defaults to None, in which case it takes the value of rcParams["scatter.edgecolors"] = 'face'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.