python config_error ai_generated true

KeyError: 'font.size' is not a valid rc parameter. See rcParams.keys() for valid parameters.

ID: python/matplotlib-rcparams-typo-error

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2024-03-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.7 active
3.8 active

Root Cause

Typo in rcParams key; correct key is 'font.size' but user might have typed 'font.size' with a dot (which is correct) or a misspelling like 'font.szie'. Actually 'font.size' is valid; the error occurs when the key is misspelled (e.g., 'font.szie' or 'fontsize').

generic

中文

rcParams键拼写错误;正确的键是'font.size',但用户可能拼写为'font.szie'或'fontsize'。

Workarounds

  1. 95% success Use the exact key from documentation
    plt.rcParams['font.size'] = 12
  2. 90% success List all rcParams to find the correct spelling
    print([key for key in plt.rcParams.keys() if 'font' in key])

Dead Ends

Common approaches that don't work:

  1. Using 'fontsize' without dot 90% fail

    The key must have a dot separating group and property; 'fontsize' is not valid.

  2. Using 'Font.size' with capital letters 85% fail

    Keys are case-sensitive; 'Font.size' is not valid.