The current style files (e.g., load_style('jupyter')) include several matplotlib.rcParams keys that are no longer valid in modern Matplotlib versions (3.6+). This results in runtime KeyError or ValueError exceptions when applying styles.
These errors originate from:
~pyOPALTools/opal/visualization/styles/default.py
Errors Encountered:
- Invalid
lines.marker value:
ValueError: Key lines.marker: Supported markers are [string, int]
Cause:
mpl.rcParams['lines.marker'] = None
None is no longer accepted — should use '' or 'None'.
-
Removed rcParam:
KeyError: 'mathtext.fallback_to_cm is not a valid rc parameter'
-
Removed rcParam:
KeyError: 'savefig.jpeg_quality is not a valid rc parameter'
Proposed fix:
Guard deprecated or removed keys before setting them:
if 'savefig.jpeg_quality' in mpl.rcParams:
mpl.rcParams['savefig.jpeg_quality'] = 95
Or more generally:
def safe_set_rcparam(key, value):
if key in matplotlib.rcParams:
matplotlib.rcParams[key] = value
Then replace direct assignments with:
safe_set_rcparam('lines.marker', '')
safe_set_rcparam('mathtext.fallback_to_cm', True)
safe_set_rcparam('savefig.jpeg_quality', 95)
This would probably restore compatibility with modern Matplotlib versions while maintaining backward compatibility.
Environment:
Python version: 3.9.6
Matplotlib version: 3.9.4
The current style files (e.g.,
load_style('jupyter')) include severalmatplotlib.rcParamskeys that are no longer valid in modern Matplotlib versions (3.6+). This results in runtimeKeyErrororValueErrorexceptions when applying styles.These errors originate from:
~pyOPALTools/opal/visualization/styles/default.pyErrors Encountered:
lines.markervalue:ValueError: Key lines.marker: Supported markers are [string, int]Cause:
Noneis no longer accepted — should use''or'None'.Removed rcParam:
KeyError: 'mathtext.fallback_to_cm is not a valid rc parameter'Removed rcParam:
KeyError: 'savefig.jpeg_quality is not a valid rc parameter'Proposed fix:
Guard deprecated or removed keys before setting them:
Or more generally:
Then replace direct assignments with:
This would probably restore compatibility with modern Matplotlib versions while maintaining backward compatibility.
Environment:
Python version: 3.9.6
Matplotlib version: 3.9.4