Warning: set it to a single string instead

What does this warning mean? How can I get rid of this?

Support for setting the 'text.latex.preamble' or 'pgf.preamble' rcParam to a list of strings is deprecated since 3.3 and will be removed two minor releases later; set it to a single string instead.
  plt.rcParams['text.latex.preamble'] = [r"\usepackage{bm}", [r"\usepackage{amsmath}"]


Code:

import matplotlib.pyplot as plt
plt.rcParams['text.latex.preamble'] = [r"\usepackage{bm}"], [r"\usepackage{amsmath}"]

params = {'text.usetex' : True,
          'font.size' : 28,
          'font.family' : 'lmodern',
          }
plt.rcParams.update(params)

Answers

As per the documentation, https://matplotlib.org/3.3.0/api/prev_api_changes/api_changes_3.3.0/deprecations.html#setting-rcparams-text-latex-preamble-default-or-rcparams-pdf-preamble-to-non-strings, setting rcParams['text.latex.preamble'] to a list of strings is no longer the correct way.

To fix this, you should replace

plt.rcParams['text.latex.preamble'] = [r"\usepackage{bm}"], [r"\usepackage{amsmath}"]

to be

plt.rcParams['text.latex.preamble'] = r"\usepackage{bm} \usepackage{amsmath}"
Posted on by Luke Roberts