I am looking for a simple way to create a title for a figure in which some words have distinct colors. So far, I have been attempting to use:
fig.text(0.35,0.85,'Black text', color="black")
fig.text(0.45,0.85,'Red text', color="red")
The problem is that I have to establish the center character of the whole string and calculate the x-coordinates accordingly, which is time-consuming.
I wish I could write the whole string in one line of code; something like this:
fig.text(.5, .85, ['Black text', 'Red text'], color = ['black', 'red'])
Or if I could create a variable for each color of code and string them together under fig.text or plt.title, that would be great.
Any ideas?
Even a way to display the pixel coordinates of each word in an existing title would help with the method I'm currently using.