Apr-17-2017, 04:54 PM
Dear Python Experts,
I created a custom colormap but noticed that my bars all got the same color.
Why is that?
Anything that helps my understanding would be much appreciated!
I created a custom colormap but noticed that my bars all got the same color.
Why is that?
Anything that helps my understanding would be much appreciated!
import pandas as pd import numpy as np import matplotlib.pyplot as plt import matplotlib.colors as clr np.random.seed(12345) df = pd.DataFrame([np.random.normal(33500,150000,3650), np.random.normal(41000,90000,3650), np.random.normal(41000,120000,3650), np.random.normal(48000,55000,3650)], index=[1992,1993,1994,1995]) numpyMatrix = df.as_matrix() #red,white,blue cmap = clr.LinearSegmentedColormap.from_list('custom red', ['#ff0000','#000000','#0000ff'], N=16) %matplotlib notebook def plot(): return df.mean(axis=1).plot.bar(colormap=cmap, width=0.9, rot=0) plot()