Reputation: 1263
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:
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?
Upvotes: 0
Views: 1941
Reputation: 339560
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.
Upvotes: 1