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

2024-09-28 20:52:48 发布

您现在位置:Python中文网/ 问答频道 /正文

如何更改matplotlib图形的颜色?现在标题是黑色的,但其他文本是灰色的。我正在使用熊猫图创建一个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 Hexbin graph


Tags: of文本import图形标题numbermatplotlib颜色