Python Forum
bar chart and custom colormap
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
bar chart and custom colormap
#1
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!

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()
Reply


Messages In This Thread
bar chart and custom colormap - by metalray - Apr-17-2017, 04:54 PM
RE: bar chart and custom colormap - by zivoni - Apr-17-2017, 08:45 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020