Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
322 views
in Technique[技术] by (71.8m points)

python 3.x - 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)
question from:https://stackoverflow.com/questions/65645194/warning-set-it-to-a-single-string-instead

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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}"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...