0

I have this script and I am not able to write + and ) bold with this font settings. How to do that? Thank you

import matplotlib.pyplot as plt
from matplotlib.text import Text

plt.rcParams['text.latex.preamble']=[r"\usepackage{bm}"]
params = {'text.usetex' : True,
          'font.size' : 28,
          'font.family' : 'lmodern',
          'text.latex.unicode': True,
          }
plt.rcParams.update(params)


fig = plt.figure(figsize=(5,5))

def setBold(txt): return r"$\bf{" + str(txt) + "}$"

plt.title(setBold("Positives") + '\n' + setBold('+'), color='red', pad = 10)

text = fig.add_artist(Text(0.5, 0.5, text=setBold('b)'), color='red')) 

plt.show()

enter image description here

Joe
  • 6,758
  • 2
  • 26
  • 47
Alex
  • 347
  • 1
  • 10
  • Thank you, it works and how to write this `plt.title(r'$\boldsymbol{\mathrm{Positives} \\ +}$', color='red', pad = 10)` to have two lines \\ and \n does not work. – Alex Apr 14 '20 at 06:00
  • 1
    Ok, please add it as an answer. – Joe Apr 14 '20 at 06:08
  • And how to write an "enter" in this kind of title? – Alex Apr 14 '20 at 08:55
  • 1
    Whatever works in Latex. https://www.overleaf.com/learn/latex/Line_breaks_and_blank_spaces#Line_breaks – Joe Apr 14 '20 at 09:21

0 Answers0