0

Is there anyway I can bold a single character in python Matplotlib with same font type?

For example: COOH

The closest solution I found using python is:

plt.xlabel('C'+r'$\bf{O}$'+'OH')

However, the font type will become math Italian and is not the same with default font type

Huhu
  • 11
  • 2

1 Answers1

0

You can do it activating latex.

from matplotlib import rc
rc('text', usetex=True)

plt.xlabel("C"+"$\textbf{O}$"+"OH")

I hope the font will stay the default type.

Only god knows
  • 307
  • 1
  • 10
  • Thanks! I try this but the error appears, mention that latex could not be found... I guess I must install the Latex first? – Huhu Aug 12 '22 at 16:02
  • You're welcome. Everything you need will probably be [there](https://stackoverflow.com/questions/58121461/runtimeerror-failed-to-process-string-with-tex-because-latex-could-not-be-found). There is a few things (`dvipng`, `latex`, `Ghostscript`) to install if it is not already done. – Only god knows Aug 12 '22 at 16:12