1

This line of code:

plt.suptitle("Observed and Predicted $U_{dec,c}$",x=mid,fontweight='bold')

Produces a suptitle like this:

enter image description here

However, I require the entire string to be in bold, including the mathematical expression, and for various reasons I need to use plt.suptitle, not plt.title. I would be grateful for any advice on how to do this.

chrisprt
  • 67
  • 6

2 Answers2

1

There are many options, a simple one is to use \mathbf:

plt.suptitle(r"Observed and Predicted $\mathbf{U_{dec,c}}$", fontweight='bold')

mathbf

You can find more options here.

mozway
  • 194,879
  • 13
  • 39
  • 75
  • Thank you; that's very helpful. But how do I keep the mathematical expression italicised, as in the image I uploaded? – chrisprt Apr 01 '22 at 13:47
1

You can use \mathbf:

from numpy import *
from matplotlib.pyplot import *
import matplotlib.pyplot as plt

rcParams['mathtext.fontset'] = 'custom'
rcParams['mathtext.it'] = 'STIXGeneral:italic'
rcParams['mathtext.bf'] = 'STIXGeneral:italic:bold'

plt.suptitle(r"Observed and Predicted $\mathbf{U_{dec,c}}$", fontweight='bold')
plt.show()

Output:

enter image description here

Credits (for italic): https://stackoverflow.com/a/44790518

Here is a list of Latex symbols.

For more questions, you can checkout this.

Abhyuday Vaish
  • 2,357
  • 5
  • 11
  • 27
  • Thank you; that's very helpful. But how do I keep the mathematical expression italicised, as in the image I uploaded? – chrisprt Apr 01 '22 at 14:08
  • @chrisprt I have edited my answer. You can check it out now! If you find the answer helpful then you can accept it.:) – Abhyuday Vaish Apr 01 '22 at 15:03