I would like to change part of a title to be bold. For example:
plt.title("This is title number: " + str(number))
Given a title like the above, how would I bold the str(number) part.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
From matplotlib version 2 on,
there is no need to use latex (which would require a working latex installation). One can use normal MathText to render part of the title in bold.
import matplotlib.pyplot as plt
number = 2017
plt.title("This is title number: " + r"$bf{" + str(number) + "}$")
plt.show()
Method 2
activate latex text rendering
from matplotlib import rc
rc('text', usetex=True)
plt.title("This is title number: " + r"textbf{" + str(number) + "}")
Method 3
This post should answer your question on manipulating the title. You can use latex text rendering and call textbf for that particular part of the string.
Styling part of label in legend in matplotlib
Here is the documentation:
http://matplotlib.org/users/usetex.html
http://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes.set_title
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0
