Skip to content

Commit 050f428

Browse files
committed
Make core wrapper funcs 'public' but hide simple ones from website
1 parent 979da4f commit 050f428

File tree

2 files changed

+37
-22
lines changed

2 files changed

+37
-22
lines changed

proplot/axes/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,15 @@
2828

2929
# Prevent importing module names and set order of appearance for objects
3030
__all__ = [
31-
'Axes', 'CartesianAxes', 'PolarAxes',
32-
'GeoAxes', 'CartopyAxes', 'BasemapAxes',
31+
'Axes',
32+
'CartesianAxes',
33+
'PolarAxes',
34+
'GeoAxes',
35+
'CartopyAxes',
36+
'BasemapAxes',
3337
'Axes3D',
34-
'ProjAxes', 'XYAxes', # deprecated
38+
# Deprecated
39+
'XYAxes',
40+
'ProjAxes',
3541
]
3642
__all__.extend(plot.__all__) # document wrappers as part of proplot/axes submodule

proplot/axes/plot.py

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@
6666
'vlines_extras',
6767
'hlines_extras',
6868
'scatter_extras',
69+
# Hidden from top-level namespace
70+
# hist_extras
71+
# stem_extras
72+
# plot_extras
73+
# plotx_extras
74+
# parametric_extras
6975
]
7076

7177

@@ -1437,7 +1443,7 @@ def indicate_error(
14371443
return res
14381444

14391445

1440-
def _plot_extras(self, func, *args, cmap=None, values=None, **kwargs):
1446+
def plot_extras(self, func, *args, cmap=None, values=None, **kwargs):
14411447
"""
14421448
Adds the option `orientation` to change the default orientation of the
14431449
lines. See also `~proplot.axes.Axes.plotx`.
@@ -1465,7 +1471,7 @@ def _plot_extras(self, func, *args, cmap=None, values=None, **kwargs):
14651471
return result
14661472

14671473

1468-
def _parametric_extras(self, func, *args, interp=0, **kwargs):
1474+
def parametric_extras(self, func, *args, interp=0, **kwargs):
14691475
"""
14701476
Calls `~proplot.axes.Axes.parametric` and optionally interpolates values before
14711477
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):
15161522
return func(self, x, y, values=values, **kwargs)
15171523

15181524

1519-
def _stem_extras(
1525+
def stem_extras(
15201526
self, func, *args, linefmt=None, basefmt=None, markerfmt=None, **kwargs
15211527
):
15221528
"""
@@ -1881,7 +1887,7 @@ def fill_betweenx_extras(self, func, *args, **kwargs):
18811887
return _fill_between_apply(self, func, *args, **kwargs)
18821888

18831889

1884-
def _hist_extras(self, func, x, bins=None, **kwargs):
1890+
def hist_extras(self, func, x, bins=None, **kwargs):
18851891
"""
18861892
Forces `bar_extras` to interpret `width` as literal rather than relative
18871893
to step size and enforces all arguments after `bins` are keyword-only.
@@ -2494,18 +2500,20 @@ def _update_cycle(self, cycle, scatter=False, **kwargs):
24942500
reset = True
24952501
break
24962502
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.
25062513
apply_manually = {} # which keys to apply from property cycler
25072514
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'}
25092517
for prop, key in (
25102518
('markersize', 's'),
25112519
('linewidth', 'linewidths'),
@@ -2664,6 +2672,7 @@ def apply_cycle(
26642672
objs = []
26652673
for i in range(ncols):
26662674
# Property cycling for scatter plots
2675+
# NOTE: See comments in _update_cycle
26672676
kw = kwargs.copy()
26682677
if apply_manually:
26692678
props = next(self._get_lines.prop_cycler)
@@ -4422,11 +4431,11 @@ def _concatenate_docstrings(func):
44224431

44234432
# Generate decorators and fill wrapper function docstrings. Each wrapper
44244433
# 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)
44304439
# Public wrapper functions providing important functionality
44314440
_apply_cmap = _process_wrapper(apply_cmap)
44324441
_apply_cycle = _process_wrapper(apply_cycle)

0 commit comments

Comments
 (0)