I have a basic data frame like this:
Mean SEM
A 21.4 2.1
B 33.5 3.4
C 16.5 3.9
D 50.1 6.1
I attempt to plot it with matplotlib like this:
plot1 = df.plot(kind="bar", yerr="SEM", y="Mean", legend=False, cmap="Greys", capsize=4, edgecolor="black")
CMAP does not work correctly. It colorizes each bar by itself, meaning that each bar has a sequential grayscale applied to it.
I want it to colorize across my bars, so that the first bar is white, the second bar is greyish, the third bar is greyish, and the final bar is ultimately black. I can achieve this with manual color filling but that's not ideal.
Here's all my code:
import pandas as pd
%matplotlib inline
# produce vector inline graphics
from IPython.display import set_matplotlib_formats
set_matplotlib_formats('pdf', 'svg')
import matplotlib.pyplot as plt
data = {'Mean':[21.4, 33.5, 16.5, 50.1],
'SEM':[2.1, 3.4, 3.9, 6.1]}
# Create DataFrame
df = pd.DataFrame(data, index=["A", "B", "C", "D"])
plot1 = df.plot(kind="bar", yerr="SEM", y="Mean", legend=False, cmap="Greys", capsize=4, edgecolor="black")