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

标签 python pandas matplotlib styles data-visualization

如何更改 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 Hexbin graph

最佳答案

为了改变轴的颜色,你可能会这样做

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') 

关于python - 如何在 Matplotlib 中更改文本颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38492333/

相关文章:

python - 使用 asyncio 的简单 Python TCP fork 服务器

python - 将数据框中的嵌套列表列更改为字典?

python - K-最近邻找到所有关系

matplotlib - Python 不断覆盖先前情节的 hist 但不使用所需的情节保存它

python - 解释 Python 分析器

Python字典理解速度很慢

python - 将第二个图例添加到散点图

python - 鼠标悬停在数据上时如何显示数据标签

python - 在cartopy(python)中获取经度和纬度的鼠标位置

python - 为 matplotlib 函数插入图例