2808 explained code solutions for 75 technologies


python-matplotlibHow to change chart font color


import matplotlib as mpl
import matplotlib.pyplot as plt

mpl.rc('text', color='red')
mpl.rc('axes', labelcolor='orange')
mpl.rc('xtick', color='blue')
mpl.rc('ytick', color='green')

plt.plot([2,1,3])
plt.xlabel("X")
plt.ylabel("Y")
plt.title('Example')

plt.show()ctrl + c
import matplotlib.pyplot as plt

loads Matplotlib module to use plotting capabilities

mpl.rc

manage configuration

'text', color

title color

'axes', labelcolor

axes labels color

'xtick', color

x value labels color

'ytick', color

y value labels color

.show()

render chart in a separate window


How to change chart font color, python matplotlib

Usage example

import matplotlib as mpl
import matplotlib.pyplot as plt

mpl.rc('text', color='red')
mpl.rc('axes', labelcolor='orange')
mpl.rc('xtick', color='blue')
mpl.rc('ytick', color='green')

plt.plot([2,1,3])
plt.xlabel("X")
plt.ylabel("Y")
plt.title('Example')

plt.show()