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.
To set the Matplotlib title in bold while using "Times New Roman", we can use fontweight="bold".
Utilizing “Times New Roman” as the font for Matplotlib's bold label. We could use attribute fontweight=”bold” to get the Matplotlib label bold when utilizing “Times New Roman.”
To do this, I would use Latex to format the text. Then I would include the 'color' package, and set your colors as you wish. I would use this one, if only it were to work with the PDF backend :) For some reason, I can never get the axes placed properly on the canvas while I am working with the ps backend.
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With