|
40 | 40 | from matplotlib.axes._base import _AxesBase |
41 | 41 | from matplotlib.axes._base import _process_plot_format |
42 | 42 |
|
| 43 | + |
43 | 44 | rcParams = matplotlib.rcParams |
44 | 45 |
|
45 | 46 | iterable = cbook.iterable |
46 | 47 | is_string_like = cbook.is_string_like |
47 | 48 | is_sequence_of_strings = cbook.is_sequence_of_strings |
48 | 49 |
|
49 | 50 |
|
| 51 | +def _plot_args_replacer(args, data): |
| 52 | + _replacer = [] |
| 53 | + remaining = args |
| 54 | + while 1: |
| 55 | + if len(remaining) == 1: |
| 56 | + |
| 57 | + msg = ("Missing argument: this can happen if a color spec " |
| 58 | + "('c') is in `data`") |
| 59 | + warnings.warn(msg, RuntimeWarning, stacklevel=3) |
| 60 | + _replacer += ["x"] |
| 61 | + elif len(remaining) == 2: |
| 62 | + _replacer += ["x", "y"] |
| 63 | + elif len(remaining) == 3: |
| 64 | + if remaining[2] in data: |
| 65 | + import warnings |
| 66 | + |
| 67 | + msg = "Found a color spec ('c') in data." |
| 68 | + warnings.warn(msg, RuntimeWarning, stacklevel=3) |
| 69 | + _replacer += ["x", "y", "c"] |
| 70 | + |
| 71 | + if len(remaining) <= 3: |
| 72 | + return _replacer |
| 73 | + |
| 74 | + # More than 3 -> split off the beginning and continue |
| 75 | + if remaining[2] not in data: |
| 76 | + _replacer += ["x", "y", "c"] |
| 77 | + isplit = 3 |
| 78 | + else: |
| 79 | + _replacer += ["x", "y"] |
| 80 | + isplit = 2 |
| 81 | + remaining = remaining[isplit:] |
| 82 | + |
| 83 | + |
50 | 84 | # The axes module contains all the wrappers to plotting functions. |
51 | 85 | # All the other methods should go in the _AxesBase class. |
52 | 86 |
|
@@ -1245,40 +1279,7 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1, |
1245 | 1279 |
|
1246 | 1280 | return colls |
1247 | 1281 |
|
1248 | | - def _plot_args_replacer(self, args, data): |
1249 | | - _replacer = [] |
1250 | | - remaining = args |
1251 | | - while 1: |
1252 | | - if len(remaining) == 1: |
1253 | | - import warnings |
1254 | | - |
1255 | | - msg = "Missing argument: this can happen if a color spec " \ |
1256 | | - "('c') is in data" |
1257 | | - warnings.warn(msg, RuntimeWarning, stacklevel=3) |
1258 | | - _replacer += ["x"] |
1259 | | - elif len(remaining) == 2: |
1260 | | - _replacer += ["x", "y"] |
1261 | | - elif len(remaining) == 3: |
1262 | | - if remaining[2] in data: |
1263 | | - import warnings |
1264 | | - |
1265 | | - msg = "Found a color spec ('c') in data." |
1266 | | - warnings.warn(msg, RuntimeWarning, stacklevel=3) |
1267 | | - _replacer += ["x", "y", "c"] |
1268 | | - |
1269 | | - if len(remaining) <= 3: |
1270 | | - return _replacer |
1271 | | - |
1272 | | - # More than 3 -> split off the beginning and continue |
1273 | | - if remaining[2] not in data: |
1274 | | - _replacer += ["x", "y", "c"] |
1275 | | - isplit = 3 |
1276 | | - else: |
1277 | | - _replacer += ["x", "y"] |
1278 | | - isplit = 2 |
1279 | | - remaining = remaining[isplit:] |
1280 | | - |
1281 | | - #### Basic plotting |
| 1282 | + # ### Basic plotting |
1282 | 1283 | # The label_naming happens in `matplotlib.axes._base._plot_args` |
1283 | 1284 | @unpack_labeled_data(replace_names=["x", "y"], |
1284 | 1285 | positional_parameter_names=_plot_args_replacer, |
|
0 commit comments