如何在Matplotlib中更改文本颜色?

5
如何更改matplotlib图表的颜色?现在标题是黑色的,但其他文本是灰色的。我正在使用Pandas绘制Hexbin图表。我已经尝试过:
matplotlib.rcParams.update({'text.color': 'black'})

http://matplotlib.org/users/customizing.html上我了解到,但它并没有起作用。
import matplotlib.pyplot as plt
import matplotlib
matplotlib.style.use('ggplot')
font = {'family' : 'normal',
        'weight' : 'bold',
        'size'   : 22}                          
matplotlib.rc('font', **font)

t = pessoas.plot.hexbin(x='qteViagens',y='qteDestUnicos',cmap=plt.cm.jet,gridsize=20,norm=matplotlib.colors.LogNorm(),colorbar=False)
t.set_xlabel('Number of Trips in Period')
t.set_ylabel('Number of Unique Destinations')
t.set_title('Number of Users')

Matplotlib六边形图

1个回答

1
为了改变轴的颜色,可以执行以下操作:
axes.xaxis.label.set_color("yellow")

axes.yaxis.label.set_color("green")

enter image description here

另外,您可以在使用 matplotlib.axes.Axes.set_xlabel 创建标签时传递标签的颜色,例如:

ax.set_xlabel('Number of Trips in Period', color='yellow') 

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接