[英]Matplotlib change bar color
Matplotlib changes the color of the bar when there are more values plotted : With 5 columns I get the expected red bars : 当绘制更多值时,Matplotlib会更改条形的颜色:使用5列,我会得到预期的红色条形:
ax = vc[vc.index[:5]].plot(color='red', kind='bar', title=col+('(count)'))
ax.set_axis_bgcolor('white')
But going for more values, the colors begin to fade and there is some grey bars appearing :( 但是要获得更多的值,颜色就会开始褪色,并且会出现一些灰色条形:(
ax = vc.plot(color='red', kind='bar', title=col+('(count)'))
ax.set_axis_bgcolor('white')
How can I keep My red bars all along ? 我如何一直保持红色条形?
They probably become gray because of the edge colors of the bars: 由于条的边缘颜色,它们可能会变成灰色:
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')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.