gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 14:08:29 27 4
gpt4 key购买 nike

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

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com