Skip to content
This repository was archived by the owner on Sep 1, 2026. It is now read-only.
This repository was archived by the owner on Sep 1, 2026. It is now read-only.

Incompatible rcParams with Newer Matplotlib Versions #102

Description

@MichZampetakis

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:

  1. 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'.

  1. Removed rcParam:
    KeyError: 'mathtext.fallback_to_cm is not a valid rc parameter'

  2. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugUsed in issue tracker to label a bug

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions