I'm trying to include an outline to lines plotted with plt.errorbar(). As suggested by Can I give a border (outline) to a line in matplotlib plot function?\,, I tried to use path_effects, however I need a different path_effect for the markers and the line.
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patheffects as pe
x = np.arange(20)
y = x**1.3
# Two lines.
fig, ax = plt.subplots()
ax.errorbar(x, y, fmt='-o', lw=5, mew=3, ms=5, c='k')
ax.errorbar(x, y, fmt='-o', lw=2, mew=0, ms=5, c='r')
# Single line with path_effects.
y += 10
ax.errorbar(x, y, fmt='-o', lw=2, mew=0, ms=5, c='b',
path_effects=[pe.Stroke(linewidth=5, foreground='k'), pe.Normal()])
which produces the following output:
.
The difference between these methods is that in the former, the outline appears as a constant width around both the line and the marker, while in the one using path_effects
, the outline is thicker around the markers. Is there a way to adjust the outline linewidth for the marker and the line separately?