Matplotlib更改条形颜色

时间:2016-05-30 10:00:00

标签: python matplotlib

当绘制更多值时,Matplotlib会更改条形图的颜色: 有5列我得到了预期的红条:

ax = vc[vc.index[:5]].plot(color='red', kind='bar', title=col+('(count)'))

    ax.set_axis_bgcolor('white')

Expected red bars

但是为了获得更多的价值,颜色开始消失,并且出现了一些灰色条纹:(

ax = vc.plot(color='red', kind='bar', title=col+('(count)'))
ax.set_axis_bgcolor('white')

Bar color change

如何一直保留我的红条?

1 个答案:

答案 0 :(得分:0)

由于条纹的边缘颜色,它们可能会变灰:

import matplotlib.pylab as pl
import numpy as np
import pandas as p

pl.figure()

x = np.arange(5)
y = np.random.random(x.size)
vc1 = p.DataFrame(data=y, index=x)

x = np.arange(100)
y = np.random.random(x.size)
vc2 = p.DataFrame(data=y, index=x)

ax = pl.subplot(131)
vc1.plot(ax=ax, kind='bar', color='red')

ax = pl.subplot(132)
vc2.plot(ax=ax, kind='bar', color='red')

ax = pl.subplot(133)
vc2.plot(ax=ax, kind='bar', color='red', edgecolor='none')

enter image description here

相关问题