|
7 | 7 | import sys |
8 | 8 |
|
9 | 9 | from matplotlib import verbose |
10 | | -from cbook import is_string_like, enumerate, strip_math |
| 10 | +from cbook import is_string_like, enumerate, strip_math, Stack |
11 | 11 | from colors import colorConverter |
12 | 12 | from numerix import array, sqrt, pi, log, asarray, ones, Float |
13 | 13 | from patches import Rectangle |
@@ -630,123 +630,22 @@ class FigureManagerBase: |
630 | 630 | def __init__(self, canvas, num): |
631 | 631 | self.canvas = canvas |
632 | 632 | self.num = num |
633 | | - self.clf() |
634 | | - |
| 633 | + |
635 | 634 | def clf(self): |
636 | 635 | 'clear the figure' |
637 | | - self.axes = {} |
638 | | - self.currentAxis = None |
| 636 | + verbose.report_error('Deprectated; use fig.clf() instead') |
639 | 637 | self.canvas.figure.clf() |
640 | 638 |
|
641 | | - def add_subplot(self, *args, **kwargs): |
642 | | - """ |
643 | | - Add a subplot to the current figure |
644 | | - """ |
645 | | - key = (args, tuple(kwargs.items())) |
646 | | - if self.axes.has_key(key): |
647 | | - self.currentAxis = self.axes[key] |
648 | | - else: |
649 | | - a = self.canvas.figure.add_subplot(*args, **kwargs) |
650 | | - self.axes[key] = a |
651 | | - self.currentAxis = a |
652 | | - return a |
653 | | - |
654 | | - def add_axes(self, rect, **kwargs): |
655 | | - """ |
656 | | - Add an axes to the current figure |
657 | | - """ |
658 | | - rect = tuple(rect) |
659 | | - key = (rect, tuple(kwargs.items())) |
660 | | - if self.axes.has_key(key): |
661 | | - self.currentAxis = self.axes[key] |
662 | | - return self.currentAxis |
663 | | - else: |
664 | | - a = self.canvas.figure.add_axes(rect, **kwargs) |
665 | | - self.axes[key] = a |
666 | | - self.currentAxis = a |
667 | | - return a |
668 | | - |
669 | | - def get_current_axis(self, **kwargs): |
670 | | - """ |
671 | | - Return the current axes |
672 | | - """ |
673 | | - if self.currentAxis is not None: |
674 | | - return self.currentAxis |
675 | | - else: |
676 | | - self.add_subplot(111, **kwargs) |
677 | | - return self.currentAxis |
678 | | - |
679 | | - |
680 | | - def set_current_axes(self, a): |
681 | | - """ |
682 | | - Set the current axes to be a |
683 | | - """ |
684 | | - if a is None: |
685 | | - self.currentAxis = None |
686 | | - return |
687 | | - if a not in self.axes.values(): |
688 | | - error_msg('Axes is not in current figure') |
689 | | - self.currentAxis = a |
690 | 639 |
|
691 | 640 | def destroy(self): |
692 | 641 | pass |
693 | 642 |
|
694 | | - |
695 | 643 | # cursors |
696 | 644 | class Cursors: #namespace |
697 | 645 | HAND, POINTER, SELECT_REGION, MOVE = range(4) |
698 | 646 | cursors = Cursors() |
699 | 647 |
|
700 | 648 |
|
701 | | -class Stack: |
702 | | - """ |
703 | | - Implement a stack where elements can be pushed on and you can move |
704 | | - back and forth. But no pop. Should mimib home / back / forward |
705 | | - in a browser |
706 | | - """ |
707 | | - |
708 | | - def __init__(self): |
709 | | - self.clear() |
710 | | - |
711 | | - def __call__(self): |
712 | | - 'return the current element, or None' |
713 | | - if not len(self._elements): return None |
714 | | - else: return self._elements[self._pos] |
715 | | - |
716 | | - def forward(self): |
717 | | - 'move the position forward and return the current element' |
718 | | - N = len(self._elements) |
719 | | - if self._pos<N-1: self._pos += 1 |
720 | | - return self() |
721 | | - |
722 | | - def back(self): |
723 | | - 'move the position back and return the current element' |
724 | | - if self._pos>0: self._pos -= 1 |
725 | | - return self() |
726 | | - |
727 | | - def push(self, o): |
728 | | - """ |
729 | | - push object onto stack at current position - all elements |
730 | | - occurring later than the current position are discarded |
731 | | - """ |
732 | | - self._elements = self._elements[:self._pos+1] |
733 | | - self._elements.append(o) |
734 | | - self._pos = len(self._elements)-1 |
735 | | - return self() |
736 | | - |
737 | | - def home(self): |
738 | | - 'push the first element onto the top of the stack' |
739 | | - if not len(self._elements): return |
740 | | - self.push(self._elements[0]) |
741 | | - return self() |
742 | | - |
743 | | - def empty(self): |
744 | | - return len(self._elements)==0 |
745 | | - |
746 | | - def clear(self): |
747 | | - 'empty the stack' |
748 | | - self._pos = -1 |
749 | | - self._elements = [] |
750 | 649 |
|
751 | 650 | class NavigationToolbar2: |
752 | 651 | """ |
|
0 commit comments