| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -91,7 +91,14 @@ def get(self, key): | |||
| 91 | 91 | item = dict(self._elements).get(key) | |
| 92 | 92 | if item is None: | |
| 93 | 93 | return None | |
| 94 | - return item[1] | ||
| 94 | + cbook.warn_deprecated( | ||
| 95 | + "2.1", | ||
| 96 | + "Adding an axes using the same arguments as a previous axes " | ||
| 97 | + "currently reuses the earlier instance. In a future version, " | ||
| 98 | + "a new instance will always be created and returned. Meanwhile, " | ||
| 99 | + "this warning can be suppressed, and the future behavior ensured, " | ||
| 100 | + "by passing a unique label to each axes instance.") | ||
| 101 | + return item[1] | ||
| 95 | 102 | ||
| 96 | 103 | def _entry_from_axes(self, e): | |
| 97 | 104 | ind, k = {a: (ind, k) for k, (ind, a) in self._elements}[e] | |
@@ -901,14 +908,14 @@ def add_axes(self, *args, **kwargs): | |||
| 901 | 908 | fig.add_axes(rect, projection='polar') | |
| 902 | 909 | fig.add_axes(ax) | |
| 903 | 910 | ||
| 904 | - If the figure already has an axes with the same parameters, | ||
| 905 | - then it will simply make that axes current and return it. If | ||
| 906 | - you do not want this behavior, e.g., you want to force the | ||
| 907 | - creation of a new Axes, you must use a unique set of args and | ||
| 908 | - kwargs. The axes :attr:`~matplotlib.axes.Axes.label` | ||
| 909 | - attribute has been exposed for this purpose. e.g., if you want | ||
| 910 | - two axes that are otherwise identical to be added to the | ||
| 911 | - figure, make sure you give them unique labels:: | ||
| 911 | + If the figure already has an axes with the same parameters, then it | ||
| 912 | + will simply make that axes current and return it. This behavior | ||
| 913 | + has been deprecated as of Matplotlib 2.1. Meanwhile, if you do | ||
| 914 | + not want this behavior (i.e., you want to force the creation of a | ||
| 915 | + new Axes), you must use a unique set of args and kwargs. The axes | ||
| 916 | + :attr:`~matplotlib.axes.Axes.label` attribute has been exposed for this | ||
| 917 | + purpose: if you want two axes that are otherwise identical to be added | ||
| 918 | + to the figure, make sure you give them unique labels:: | ||
| 912 | 919 | ||
| 913 | 920 | fig.add_axes(rect, label='axes1') | |
| 914 | 921 | fig.add_axes(rect, label='axes2') | |
@@ -996,14 +1003,14 @@ def add_subplot(self, *args, **kwargs): | |||
| 996 | 1003 | ----- | |
| 997 | 1004 | If the figure already has a subplot with key (*args*, | |
| 998 | 1005 | *kwargs*) then it will simply make that subplot current and | |
| 999 | - return it. | ||
| 1006 | + return it. This behavior is deprecated. | ||
| 1000 | 1007 | ||
| 1001 | 1008 | Examples | |
| 1002 | 1009 | -------- | |
| 1003 | 1010 | fig.add_subplot(111) | |
| 1004 | 1011 | ||
| 1005 | 1012 | # equivalent but more general | |
| 1006 | - fig.add_subplot(1,1,1) | ||
| 1013 | + fig.add_subplot(1, 1, 1) | ||
| 1007 | 1014 | ||
| 1008 | 1015 | # add subplot with red background | |
| 1009 | 1016 | fig.add_subplot(212, facecolor='r') | |
@@ -1022,18 +1029,17 @@ def add_subplot(self, *args, **kwargs): | |||
| 1022 | 1029 | return | |
| 1023 | 1030 | ||
| 1024 | 1031 | if len(args) == 1 and isinstance(args[0], int): | |
| 1025 | - args = tuple([int(c) for c in str(args[0])]) | ||
| 1026 | - if len(args) != 3: | ||
| 1027 | - raise ValueError("Integer subplot specification must " + | ||
| 1028 | - "be a three digit number. " + | ||
| 1029 | - "Not {n:d}".format(n=len(args))) | ||
| 1032 | + if not 100 <= args[0] <= 999: | ||
| 1033 | + raise ValueError("Integer subplot specification must be a " | ||
| 1034 | + "three-digit number, not {}".format(args[0])) | ||
| 1035 | + args = tuple(map(int, str(args[0]))) | ||
| 1030 | 1036 | ||
| 1031 | 1037 | if isinstance(args[0], SubplotBase): | |
| 1032 | 1038 | ||
| 1033 | 1039 | a = args[0] | |
| 1034 | 1040 | if a.get_figure() is not self: | |
| 1035 | - msg = ("The Subplot must have been created in the present" | ||
| 1036 | - " figure") | ||
| 1041 | + msg = ("The Subplot must have been created in the present " | ||
| 1042 | + "figure") | ||
| 1037 | 1043 | raise ValueError(msg) | |
| 1038 | 1044 | # make a key for the subplot (which includes the axes object id | |
| 1039 | 1045 | # in the hash) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments