2015-09-06 145 views
0

是否有任何参数或功能可帮助我排除例如黄色颜色来自所选的颜色映射?从组中的颜色映射中排除特定的颜色/颜色

MWE

import pandas as pd 
import numpy as np 

index=pd.date_range('2011-1-1 00:00:00', '2011-12-31 23:50:00', freq='1h') 
df=pd.DataFrame(np.random.randn(len(index),3).cumsum(axis=0),columns=['A','B','C'],index=index) 

df2 = df.groupby(lambda x: x.month) 

for key, group in df2: 
    group.plot(colormap='gnuplot') 

回答

1

可以切成喜欢的颜色表:

import pandas as pd 
import numpy as np 
from matplotlib import pyplot as plt 
%matplotlib inline 

index=pd.date_range('2011-1-1 00:00:00', '2011-12-31 23:50:00', freq='1h') 
df=pd.DataFrame(np.random.randn(len(index),3).cumsum(axis=0),columns=['A','B','C'],index=index) 

df2 = df.groupby(lambda x: x.month) 
''' 
you can define the slize of the colormap in the range from 0 to 1 
by calling np.linspace I created three colors ranging from 0 to 70 % 
of the colors from the chosen colormap. The first two arguments 
define the slize of the colormap, the last one defines the number 
of colors''' 
cm = plt.cm.gnuplot(np.linspace(0,0.7,3)) 
for i, item in enumerate(df2): 
    key, group = item 
    group.plot(color=cm) 
+0

将您可以简单介绍一下什么是数字在'np.linspace(0,0.7,3) ' – Michal

+0

太好了。谢谢 ! – Michal