Skip to content

WIP : draft of replacement for pyplot #3587

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

Closed
wants to merge 1 commit into from
Closed
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
48 changes: 48 additions & 0 deletions lib/matplotlib/pyplot_nng.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six
import matplotlib.pyplot as plt # to grab figure management stuff
from matplotlib.axes import Axes
import functools


# apparently, raw object objects use slots.
class Dummy(object):
pass

pyplot_nng = Dummy()
interactive = Dummy()


def interactive_wrapper(func):
@functools.wraps(func)
def inner(ax, *args, **kwargs):
ret_list = func(ax, *args, **kwargs)
ax.figure.canvas.draw()
return ret_list

return inner


def wrap_for_pyplot(func):
def inner(*args, **kwargs):
ax = plt.gca()
art_list = func(ax, *args, **kwargs)
ax.figure.canvas.draw()
return art_list

inner.__name__ = func.__name__
# This should be modified to strip the docs
# if the axes as the first argument is documented
inner.__doc__ = func.__doc__
return inner

funcs_to_wrap = [atr for atr in
(getattr(Axes, atr_name) for atr_name in dir(Axes)
if not atr_name.startswith('_'))
if callable(atr)]

for f in funcs_to_wrap:
setattr(pyplot_nng, f.__name__, wrap_for_pyplot(f))
setattr(interactive, f.__name__, interactive_wrapper(f))