Issue
I wanted to plot a function on a black colored background. I already managed to modify the labels etc. but I don't know the command to change the color of the title solely.
Example
import numpy as np
import matplotlib.pyplot as plt
fig1, ax1 = plt.subplots(1,1)
fig1.patch.set_facecolor('k')
ax1.set_facecolor('k')
ax1.xaxis.label.set_color('w')
ax1.yaxis.label.set_color('w')
ax1.spines['bottom'].set_color('w')
ax1.spines['top'].set_color('w')
ax1.spines['left'].set_color('w')
ax1.spines['right'].set_color('w')
ax1.tick_params(axis='both', colors='w')
x=np.linspace(0,10,1000)
ax1.plot(x, np.exp(x))
ax1.set_title('This title\'s color should be modified afterwards', color='w')
I need this for a GUI I created. I don't want to change the rcParams of the matplotlib module. I want to enter a command similar to above.
Solution
You can use the set_color
method:
ax1.title.set_color('blue')
Answered By - Shlomo Gottlieb
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.