Closed
Description
I cannot get the new prop cycler to work with bar plots, it does not pick up the cycler properties at all.
I have minimally adapted the cycler demo to show this - see the ax1.bar
calls. Running this gives two blue and one red bar plot, when it should give (in my expectation) one cyan, one magenta (from the cycle) and one red (manually set). The top axis' plot gets cycled correctly.
from cycler import cycler
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 2 * np.pi)
offsets = np.linspace(0, 2*np.pi, 4, endpoint=False)
# Create array with shifted-sine curve along each column
yy = np.transpose([np.sin(x + phi) for phi in offsets])
plt.rc('lines', linewidth=4)
plt.rc('axes', prop_cycle=(cycler('color', ['r', 'g', 'b', 'y']) +
cycler('linestyle', ['-', '--', ':', '-.'])))
fig, (ax0, ax1) = plt.subplots(nrows=2)
ax0.plot(yy)
ax0.set_title('Set default color cycle to rgby')
ax1.set_prop_cycle(cycler('color', ['c', 'm', 'y', 'k']) +
cycler('lw', [1, 2, 3, 4]))
# ax1.plot(yy) # original
ax1.bar(x, yy[:,1]) # a simple bar plot from the available data
ax1.bar(x, yy[:,2]) # both these come out as blue
ax1.bar(x, yy[:,3], color='r') # this works, gives red bars, so "color" is recognized!
ax1.set_title('Set axes color cycle to cmyk')
# Tweak spacing between subplots to prevent labels from overlapping
plt.subplots_adjust(hspace=0.3)
plt.show()
This is on mpl 1.5.1. Is this pebkac, or does the cycler only work for some plots (if so, which ones)?
Also, are hatches supported by this, too (I mean, as soon as it works)? That's what I ultimately want to do.