8000 Simplify _process_plot_var_args.set_prop_cycle. by anntzer · Pull Request #20201 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Simplify _process_plot_var_args.set_prop_cycle. #20201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,26 +223,21 @@ class _process_plot_var_args:
def __init__(self, axes, command='plot'):
self.axes = axes
self.command = command
self.set_prop_cycle()
self.set_prop_cycle(None)

def __getstate__(self):
# note: it is not possible to pickle a generator (and thus a cycler).
return {'axes': self.axes, 'command': self.command}

def __setstate__(self, state):
self.__dict__ = state.copy()
self.set_prop_cycle()
self.set_prop_cycle(None)

def set_prop_cycle(self, *args, **kwargs):
# Can't do `args == (None,)` as that crashes cycler.
if not (args or kwargs) or (len(args) == 1 and args[0] is None):
prop_cycler = mpl.rcParams['axes.prop_cycle']
else:
prop_cycler = cycler(*args, **kwargs)

self.prop_cycler = itertools.cycle(prop_cycler)
# This should make a copy
self._prop_keys = prop_cycler.keys
def set_prop_cycle(self, cycler):
if cycler is None:
cycler = mpl.rcParams['axes.prop_cycle']
self.prop_cycler = itertools.cycle(cycler)
self._prop_keys = cycler.keys # This should make a copy

def __call__(self, *args, data=None, **kwargs):
self.axes._process_unit_info(kwargs=kwargs)
Expand Down
0