|
66 | 66 | 'vlines_extras', |
67 | 67 | 'hlines_extras', |
68 | 68 | 'scatter_extras', |
| 69 | + # Hidden from top-level namespace |
| 70 | + # hist_extras |
| 71 | + # stem_extras |
| 72 | + # plot_extras |
| 73 | + # plotx_extras |
| 74 | + # parametric_extras |
69 | 75 | ] |
70 | 76 |
|
71 | 77 |
|
@@ -1437,7 +1443,7 @@ def indicate_error( |
1437 | 1443 | return res |
1438 | 1444 |
|
1439 | 1445 |
|
1440 | | -def _plot_extras(self, func, *args, cmap=None, values=None, **kwargs): |
| 1446 | +def plot_extras(self, func, *args, cmap=None, values=None, **kwargs): |
1441 | 1447 | """ |
1442 | 1448 | Adds the option `orientation` to change the default orientation of the |
1443 | 1449 | lines. See also `~proplot.axes.Axes.plotx`. |
@@ -1465,7 +1471,7 @@ def _plot_extras(self, func, *args, cmap=None, values=None, **kwargs): |
1465 | 1471 | return result |
1466 | 1472 |
|
1467 | 1473 |
|
1468 | | -def _parametric_extras(self, func, *args, interp=0, **kwargs): |
| 1474 | +def parametric_extras(self, func, *args, interp=0, **kwargs): |
1469 | 1475 | """ |
1470 | 1476 | Calls `~proplot.axes.Axes.parametric` and optionally interpolates values before |
1471 | 1477 | they get passed to `apply_cmap` and the colormap boundaries are drawn. Full |
@@ -1516,7 +1522,7 @@ def _parametric_extras(self, func, *args, interp=0, **kwargs): |
1516 | 1522 | return func(self, x, y, values=values, **kwargs) |
1517 | 1523 |
|
1518 | 1524 |
|
1519 | | -def _stem_extras( |
| 1525 | +def stem_extras( |
1520 | 1526 | self, func, *args, linefmt=None, basefmt=None, markerfmt=None, **kwargs |
1521 | 1527 | ): |
1522 | 1528 | """ |
@@ -1881,7 +1887,7 @@ def fill_betweenx_extras(self, func, *args, **kwargs): |
1881 | 1887 | return _fill_between_apply(self, func, *args, **kwargs) |
1882 | 1888 |
|
1883 | 1889 |
|
1884 | | -def _hist_extras(self, func, x, bins=None, **kwargs): |
| 1890 | +def hist_extras(self, func, x, bins=None, **kwargs): |
1885 | 1891 | """ |
1886 | 1892 | Forces `bar_extras` to interpret `width` as literal rather than relative |
1887 | 1893 | to step size and enforces all arguments after `bins` are keyword-only. |
@@ -2494,18 +2500,20 @@ def _update_cycle(self, cycle, scatter=False, **kwargs): |
2494 | 2500 | reset = True |
2495 | 2501 | break |
2496 | 2502 | if reset: |
2497 | | - self.set_prop_cycle(cycle) |
2498 | | - |
2499 | | - # Psuedo-expansion of matplotlib's native property cycling for scatter(). Check out |
2500 | | - # the current property cycle for extra keys not interpreted by matplotlib (all keys |
2501 | | - # other than color, linestyle, and dashes). If they are present, and the user didn't |
2502 | | - # explicitly override them with some other keyword arg, then take note of that. |
2503 | | - # NOTE: By default matplotlib uses _get_patches_for_fill.get_next_color |
2504 | | - # for scatter next scatter color, but cannot get anything else! We simultaneously |
2505 | | - # iterate through the _get_lines property cycler and apply relevant properties. |
| 2503 | + self.set_prop_cycle(cycle) # updates both _get_lines and _get_patches_for_fill |
| 2504 | + |
| 2505 | + # Psuedo-expansion of matplotlib's property cycling for scatter(). Return dict |
| 2506 | + # of cycle keys and translated scatter() keywords for those not specified by user |
| 2507 | + # NOTE: This is similar to _process_plot_var_args._getdefaults but want to rely |
| 2508 | + # minimally on private API. |
| 2509 | + # NOTE: By default matplotlib uses the property cycler in _get_patches_for_fill |
| 2510 | + # for scatter() plots. It also only inherits color from that cycler. We instead |
| 2511 | + # use _get_lines with scatter() to help overarching goal of unifying plot() and |
| 2512 | + # scatter(). Now shading/bars loop over one cycle, plot/scatter along another. |
2506 | 2513 | apply_manually = {} # which keys to apply from property cycler |
2507 | 2514 | if scatter: |
2508 | | - prop_keys = set(self._get_lines._prop_keys) - {'color', 'linestyle', 'dashes'} |
| 2515 | + parser = self._get_lines # the _process_plot_var_args instance |
| 2516 | + prop_keys = set(parser.prop_cycler.keys) - {'color', 'linestyle', 'dashes'} |
2509 | 2517 | for prop, key in ( |
2510 | 2518 | ('markersize', 's'), |
2511 | 2519 | ('linewidth', 'linewidths'), |
@@ -2664,6 +2672,7 @@ def apply_cycle( |
2664 | 2672 | objs = [] |
2665 | 2673 | for i in range(ncols): |
2666 | 2674 | # Property cycling for scatter plots |
| 2675 | + # NOTE: See comments in _update_cycle |
2667 | 2676 | kw = kwargs.copy() |
2668 | 2677 | if apply_manually: |
2669 | 2678 | props = next(self._get_lines.prop_cycler) |
@@ -4422,11 +4431,11 @@ def _concatenate_docstrings(func): |
4422 | 4431 |
|
4423 | 4432 | # Generate decorators and fill wrapper function docstrings. Each wrapper |
4424 | 4433 | # function should call function(self, ...) somewhere. |
4425 | | -# Hidden wrapper functions providing only internal functionality |
4426 | | -_hist_extras = _process_wrapper(_hist_extras) |
4427 | | -_stem_extras = _process_wrapper(_stem_extras) |
4428 | | -_plot_extras = _process_wrapper(_plot_extras) |
4429 | | -_parametric_extras = _process_wrapper(_parametric_extras) |
| 4434 | +# Hidden functions providing only internal functionality |
| 4435 | +_hist_extras = _process_wrapper(hist_extras) |
| 4436 | +_stem_extras = _process_wrapper(stem_extras) |
| 4437 | +_plot_extras = _process_wrapper(plot_extras) |
| 4438 | +_parametric_extras = _process_wrapper(parametric_extras) |
4430 | 4439 | # Public wrapper functions providing important functionality |
4431 | 4440 | _apply_cmap = _process_wrapper(apply_cmap) |
4432 | 4441 | _apply_cycle = _process_wrapper(apply_cycle) |
|
0 commit comments