是否有任何参数或功能可帮助我从所选色彩图中排除黄色颜色?
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')
答案 0 :(得分: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)