Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b9667cf
Initial commit
lukelbd Dec 19, 2019
83ef32c
Merge branch 'master' into rc-cleanup-fixes
lukelbd Jan 6, 2020
e464a99
Move default props from .proplotrc --> rctools.py
lukelbd Jan 6, 2020
e760807
Improve rc_configurator getitem/setitem, add helper func
lukelbd Jan 6, 2020
d6b6020
Update get(), fill(), category(); add dict() and iterator methods
lukelbd Jan 6, 2020
a82dd68
Fix rc_configurator.context() bug
lukelbd Jan 6, 2020
dea6d94
Improve iter, contains, and string repr methods
lukelbd Jan 6, 2020
44a4bc9
Improve _loc_translate + _get_title_props, related cleanup
lukelbd Jan 7, 2020
424bc67
Remove Axes.context, update rc lookups, related cleanup
lukelbd Jan 7, 2020
8e7655e
Add x/ylinewidth, x/ygridcolor XYAxes.format kwargs
lukelbd Jan 7, 2020
25f7bd8
Fix rc lookups in other files
lukelbd Jan 7, 2020
77e406a
Remove Axes.context, add documented Axes.number prop
lukelbd Jan 7, 2020
61a45d4
Update changelog and index
lukelbd Jan 7, 2020
93c8aa5
Cleaner install instructions
lukelbd Jan 7, 2020
da123eb
Remove rc._init reference
lukelbd Jan 7, 2020
5b45522
Fix bug/conflict between ipython_* funcs and rc.__init__
lukelbd Jan 7, 2020
1bf78ce
Remove _getitem_mode assignment
lukelbd Jan 7, 2020
3c44865
Add _get_space function, simplify _panel_kwargs function
lukelbd Jan 7, 2020
3fb9a52
Rename _panel_kwargs --> _get_panelargs
lukelbd Jan 7, 2020
dba9f70
Use _get_space; remove refs to subplots.ylabspace, etc.
lukelbd Jan 7, 2020
fdfe042
Update default font sizes
lukelbd Jan 7, 2020
3218c2a
Change refs from panelspace --> panelpad
lukelbd Jan 7, 2020
1ab92ca
Remove subplots.ylabspace, etc. from configuration docs
lukelbd Jan 7, 2020
16ae44f
Fix _loc_translate bug
lukelbd Jan 7, 2020
6629efb
Remove panel_kw from colorbar/legend_wrapper
lukelbd Jan 7, 2020
ef33694
Update changelog
lukelbd Jan 7, 2020
20b9f5b
No longer change figure.dpi
lukelbd Jan 7, 2020
db78bc0
Fix rc.category bug, minor subplots bugs
lukelbd Jan 7, 2020
c57c7b0
Prefer closing brackets on new lines
lukelbd Jan 7, 2020
578aa8b
Better install instructions
lukelbd Jan 7, 2020
7acffb6
Update changelog
lukelbd Jan 7, 2020
8da19f5
Remove outdated cache=False ref, remove debug statement
lukelbd Jan 7, 2020
3ca9a02
Minor BasemapAxes bugfix
lukelbd Jan 7, 2020
22af8f9
Notebook examples formatting improvements
lukelbd Jan 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove Axes.context, add documented Axes.number prop
  • Loading branch information
lukelbd committed Jan 7, 2020
commit 77e406a784a8d378d9edc4144285863b4a7c1135
100 changes: 23 additions & 77 deletions proplot/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def __init__(self, *args, number=None,
# Ensure isDefault_minloc enabled at start, needed for dual axes
self.xaxis.isDefault_minloc = self.yaxis.isDefault_minloc = True
# Properties
self._number = number # for abc numbering
self.number = number
self._abc_loc = None
self._abc_text = None
self._titles_dict = {} # dictionary of titles and locs
Expand Down Expand Up @@ -326,6 +326,18 @@ def _get_title_props(self, abc=False, loc=None):
kw.pop('linewidth', None)
return loc, obj, kw

def _iter_panels(self, sides='lrbt'):
"""Return a list of axes and child panel axes."""
axs = [self] if self.get_visible() else []
if not ({*sides} <= {*'lrbt'}):
raise ValueError(f'Invalid sides {sides!r}.')
for s in sides:
for ax in getattr(self, '_' + s + 'panels'):
if not ax or not ax.get_visible():
continue
axs.append(ax)
return axs

@staticmethod
def _loc_translate(loc, default=None):
"""Return the location string `loc` translated into a standardized
Expand Down Expand Up @@ -604,64 +616,6 @@ def _update_title(self, obj, **kwargs):
y = _notNone(kwargs.pop('y', y), pos[1])
return self.text(x, y, text, **kwextra)

def context(self, *, mode=2, rc_kw=None, **kwargs):
"""
For internal use. Sets up temporary `~proplot.rctools.rc` settings by
returning the result of `~proplot.rctools.rc_configurator.context`.

Parameters
----------
rc_kw : dict, optional
A dictionary containing "rc" configuration settings that will
be applied to this axes. Temporarily updates the
`~proplot.rctools.rc` object.
**kwargs
Any of three options:

* A keyword arg for `Axes.format`, `XYAxes.format`,
or `ProjAxes.format`.
* A global "rc" keyword arg, like ``linewidth`` or ``color``.
* A standard "rc" keyword arg **with the dots omitted**,
like ``landcolor`` instead of ``land.color``.

The latter two options update the `~proplot.rctools.rc`
object, just like `rc_kw`.

Other parameters
----------------
mode : int, optional
The "getitem mode". This is used under-the-hood -- you shouldn't
have to use it directly. Determines whether queries to the
`~proplot.rctools.rc` object will ignore
`rcParams <https://matplotlib.org/users/customizing.html>`__.
This can help prevent a massive number of unnecessary lookups
when the settings haven't been changed by the user.
See `~proplot.rctools.rc_configurator` for details.

Returns
-------
`~proplot.rctools.rc_configurator`
The `proplot.rctools.rc` object primed for use in a "with"
statement.
dict
Dictionary of keyword arguments that are not `~proplot.rctools.rc`
properties, to be passed to the ``format`` methods.
"""
# Figure out which kwargs are valid rc settings
# TODO: Support for 'small', 'large', etc. font
kw = {} # for format
rc_kw = rc_kw or {}
for key, value in kwargs.items():
key_fixed = RC_NODOTSNAMES.get(key, None)
if key_fixed is None:
kw[key] = value
else:
rc_kw[key_fixed] = value
rc._getitem_mode = 0 # might still be non-zero if had error
# Return "context object", which is just the configurator itself
# primed for use in a "with" statement
return rc.context(rc_kw, mode=mode), kw

def format(
self, *, title=None, top=None,
figtitle=None, suptitle=None, rowlabels=None, collabels=None,
Expand Down Expand Up @@ -953,8 +907,7 @@ def colorbar(self, *args, loc=None, pad=None,
For outer colorbars only. The space between the colorbar and the
main axes. Units are interpreted by `~proplot.utils.units`.
When :rcraw:`tight` is ``True``, this is adjusted automatically.
When :rcraw:`tight` is ``False``, the default is
:rc:`subplots.panelspace`.
Otherwise, the default is :rc:`subplots.panelspace`.
frame, frameon : bool, optional
For inset colorbars, indicates whether to draw a "frame", just
like `~matplotlib.axes.Axes.legend`. Default is
Expand Down Expand Up @@ -1175,8 +1128,7 @@ def legend(self, *args, loc=None, width=None, space=None, **kwargs):
For outer legends only. The space between the axes and the legend
box. Units are interpreted by `~proplot.utils.units`.
When :rcraw:`tight` is ``True``, this is adjusted automatically.
When :rcraw:`tight` is ``False``, the default is
:rc:`subplots.panelspace`.
Otherwise, the default is :rc:`subplots.panelspace`.

Other parameters
----------------
Expand Down Expand Up @@ -1398,7 +1350,7 @@ def panel_axes(self, side, **kwargs):
space : float or str or list thereof, optional
Empty space between the main subplot and the panel.
When :rcraw:`tight` is ``True``, this is adjusted automatically.
Otherwise, defaut is :rc:`subplots.panelspace`.
Otherwise, the default is :rc:`subplots.panelspace`.
share : bool, optional
Whether to enable axis sharing between the *x* and *y* axes of the
main subplot and the panel long axes for each panel in the stack.
Expand Down Expand Up @@ -1535,22 +1487,16 @@ def violins(self, *args, **kwargs):

@property
def number(self):
"""The axes number, controls a-b-c label order and order of
appearence in the `~proplot.subplots.subplot_grid` returned by
"""The axes number. This controls the order of a-b-c labels and the
order of appearence in the `~proplot.subplots.subplot_grid` returned by
`~proplot.subplots.subplots`."""
return self._number

def _iter_panels(self, sides='lrbt'):
"""Iterates over axes and child panel axes."""
axs = [self] if self.get_visible() else []
if not ({*sides} <= {*'lrbt'}):
raise ValueError(f'Invalid sides {sides!r}.')
for s in sides:
for ax in getattr(self, '_' + s + 'panels'):
if not ax or not ax.get_visible():
continue
axs.append(ax)
return axs
@number.setter
def number(self, num):
if not isinstance(num, Integral) or num < 1:
raise ValueError(f'Invalid number {num!r}. Must be integer >=1.')
self._number = num

# Wrapped by special functions
# Also support redirecting to Basemap methods
Expand Down