Closed
Description
If the linestyles used in a plt.errorbar
plot are adjusted manually, results are as expected. However, when using a linestyle
cycler, the linestyles are simply ignored whereas using a ls
cycler results in errorbar end points being connected by lines.
Consider the following minimal example
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from cycler import cycler
x = np.arange(0.1, 4, 0.5)
y = np.exp(-x)
offsets = [0, 1]
linestyles = ['-', '--']
plt.figure()
for offset, linestyle in zip(offsets, linestyles):
plt.errorbar(x, y + offset, xerr=0.1, yerr=0.3, ls=linestyle, color='b')
plt.title('manual plots')
plt.savefig('manual_plots.png')
linestyle_cycle = cycler('linestyle', linestyles)
mpl.rcParams['axes.prop_cycle'] = linestyle_cycle
plt.figure()
for offset in offsets:
plt.errorbar(x, y + offset, xerr=0.1, yerr=0.3, color='b')
plt.title('Linestyle cycler plots')
plt.savefig('linestyle_cycler_plots.png')
ls_cycle = cycler('ls', linestyles)
mpl.rcParams['axes.prop_cycle'] = ls_cycle
plt.figure()
for offset in offsets:
plt.errorbar(x, y + offset, xerr=0.1, yerr=0.3, color='b')
plt.title('ls cycler plots')
plt.savefig('ls_cycler_plots.png')
which produces the following set of figures
I ran the above example using Anaconda 4.1.1 with Python 3.5.2 and Matplotlib 1.5.1 on Linux.