如何更改 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")
或者,可以在使用
matplotlib.axes.Axes.set_xlabel
创建标签时传递标签的颜色。 , 如ax.set_xlabel('Number of Trips in Period', color='yellow')
关于python - 如何在 Matplotlib 中更改文本颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38492333/