Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5b09d89
Try to pop vmin and vmax out of norm_kw
lukelbd Sep 2, 2019
a3ebbb1
Respect vmin and vmax as hard minimum/maximum
lukelbd Sep 2, 2019
ba2ce6f
Merge branch 'master' into panels-change-gridspec
lukelbd Sep 2, 2019
bad8024
Remove PanelAxes, and remove 'panels' args from subplots()! Colorbar …
lukelbd Sep 3, 2019
aa4cccf
On-the-fly figure colorbars and legends!
lukelbd Sep 3, 2019
c264999
Return axes_grid of panels, fix _panels_kwargs bug
lukelbd Sep 3, 2019
088a537
Fix axes_grid docstring
lukelbd Sep 3, 2019
bf87d3a
Minor
lukelbd Sep 3, 2019
cfe7e66
axes_grid docstring
lukelbd Sep 3, 2019
3205230
Zoom attribute change
lukelbd Sep 3, 2019
00bd9ff
Auto legend cleanup
lukelbd Sep 3, 2019
25934db
Comments
lukelbd Sep 3, 2019
73dd02c
Better 'span' fig panel aliases
lukelbd Sep 3, 2019
9254346
Add AAAS to journals; fix bug in pulling their dims
bradyrx Sep 4, 2019
32c4cc8
Move journal dictionary to top; add testing for journals
bradyrx Sep 4, 2019
7b6e4e0
Misc bugfixes and cleanup
lukelbd Sep 5, 2019
b8df9e1
Panels bugfix
lukelbd Sep 5, 2019
c67c3f8
Remove print statement
lukelbd Sep 5, 2019
5643867
Update documentation to reflect new colorbars, legends usage, add ins…
lukelbd Sep 5, 2019
4a43155
Merge pull request #31 from lukelbd/panels-change-gridspec
lukelbd Sep 5, 2019
acc905c
Remove duplicate 'Plotting wrappers' docs
lukelbd Sep 5, 2019
c2ae600
All caps constants
lukelbd Sep 6, 2019
f9c6eda
Name change fix
lukelbd Sep 6, 2019
c880ef1
Figure documentation
lukelbd Sep 6, 2019
7a611b5
_subplots_geometry cleanup
lukelbd Sep 6, 2019
43943a7
Merge pull request #30 from bradyrx/add_aaas_journals
lukelbd Sep 6, 2019
ddcc5fe
Repair dead links in wrappers.py
lukelbd Sep 6, 2019
bb3f21a
Merge branch 'master' of https://github.com/lukelbd/proplot
lukelbd Sep 6, 2019
039aea3
Demo stacked figure panels
lukelbd Sep 6, 2019
8804efc
_reassign_title bugfix, minor docs changes
lukelbd Sep 9, 2019
2b78889
Preliminary add_subplot changes
lukelbd Sep 9, 2019
695318b
Merge from master
lukelbd Sep 14, 2019
513d3e0
Fix import error
lukelbd Sep 14, 2019
ff760aa
Merge and fix docs conflicts
lukelbd Sep 18, 2019
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
All caps constants
  • Loading branch information
lukelbd committed Sep 6, 2019
commit c2ae60073540c8e9a2a3ac7c0a5f9f38d1eab7b1
16 changes: 8 additions & 8 deletions proplot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,36 @@ def _warning_proplot(message, category, filename, lineno, line=None):
# of other modules last, and loads styletools early so we can try to update
# TTFPATH before the fontManager is loaded by other matplotlib modules
from .utils import * # misc stuff, debug mode
if _debug:
if DEBUG:
import time
t = time.clock()
t0 = t
from .styletools import * # colors and fonts
if _debug:
if DEBUG:
print(f'styletools: {time.clock() - t}')
t = time.clock()
from .rctools import * # custom configuration implementation
if _debug:
if DEBUG:
print(f'rctools: {time.clock() - t}')
t = time.clock()
from .axistools import * # locators, normalizers, and formatters
if _debug:
if DEBUG:
print(f'axistools: {time.clock() - t}')
t = time.clock()
from .wrappers import * # wrappers
if _debug:
if DEBUG:
print(f'wrappers: {time.clock() - t}')
t = time.clock()
from .projs import * # projections and whatnot
if _debug:
if DEBUG:
print(f'projs: {time.clock() - t}')
t = time.clock()
from .axes import * # axes classes
if _debug:
if DEBUG:
print(f'axes: {time.clock() - t}')
t = time.clock()
from .subplots import * # subplots and figure class
if _debug:
if DEBUG:
print(f'subplots: {time.clock() - t}')
t = time.clock()
print(f'total time: {time.clock() - t0}')
Expand Down
39 changes: 25 additions & 14 deletions proplot/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
import matplotlib.gridspec as mgridspec
import matplotlib.transforms as mtransforms
import matplotlib.collections as mcollections
from .rctools import rc, _rc_names_nodots
from .rctools import rc, RC_NAMES_NODOTS
from . import utils, projs, axistools, wrappers
from .utils import _notNone, units
__all__ = [
Expand All @@ -63,13 +63,13 @@
]

# Translator for inset colorbars and legends
_side_translate = {
SIDE_TRANSLATE = {
'l':'left',
'r':'right',
'b':'bottom',
't':'top',
}
_loc_translate = {
LOC_TRANSLATE = {
None:None,
'l':'left',
'r':'right',
Expand Down Expand Up @@ -99,13 +99,13 @@
}

# Helper function
_abc_string = 'abcdefghijklmnopqrstuvwxyz'
ABC_STRING = 'abcdefghijklmnopqrstuvwxyz'
def _abc(i):
"""Function for a-b-c labeling, returns a...z...aa...zz...aaa...zzz."""
if i < 26:
return _abc_string[i]
return ABC_STRING[i]
else:
return _abc(i - 26) + _abc_string[i % 26] # sexy sexy recursion
return _abc(i - 26) + ABC_STRING[i % 26] # sexy sexy recursion

# Import mapping toolbox
try:
Expand Down Expand Up @@ -192,8 +192,9 @@ def __init__(self, *args, number=None,

@wrappers._expand_methods_list
def __getattribute__(self, attr, *args):
"""Applies the `~proplot.wrappers.text_wrapper` wrapper and disables
the redundant methods `_disabled_methods`."""
"""Disables the redundant methods `DISABLED_METHODS` with useful
error messages, and applies the `~proplot.wrappers.text_wrapper`
wrapper."""
obj = object.__getattribute__(self, attr, *args)
for message,attrs in wrappers._disabled_methods.items():
if attr in attrs:
Expand Down Expand Up @@ -254,7 +255,7 @@ def _get_title_props(self, abc=False, loc=None):
cache = False

# Above axes
loc = _loc_translate.get(loc, loc)
loc = LOC_TRANSLATE.get(loc, loc)
if loc in ('top','bottom'):
raise ValueError(f'Invalid title location {loc!r}.')
elif loc in ('left','right','center'):
Expand Down Expand Up @@ -298,7 +299,7 @@ def _loc_translate(loc, **kwargs):
if loc is True:
loc = None
elif isinstance(loc, (str, Integral)):
loc = _loc_translate.get(loc, loc) # may still be invalid
loc = LOC_TRANSLATE.get(loc, loc) # may still be invalid
return loc

def _make_inset_locator(self, bounds, trans):
Expand Down Expand Up @@ -340,7 +341,7 @@ def _reassign_suplabel(self, side):
# this is called on the main axes *or* on the relevant panel itself
# TODO: Mixed figure panels with super labels? How does that work?
s = side[0]
side = _side_translate[s]
side = SIDE_TRANSLATE[s]
if s == self._panel_side:
ax = self._panel_parent
else:
Expand Down Expand Up @@ -588,7 +589,7 @@ def context(self, *, mode=2, rc_kw=None, **kwargs):
kw = {} # for format
rc_kw = rc_kw or {}
for key,value in kwargs.items():
key_fixed = _rc_names_nodots.get(key, None)
key_fixed = RC_NAMES_NODOTS.get(key, None)
if key_fixed is None:
kw[key] = value
else:
Expand Down Expand Up @@ -801,6 +802,11 @@ def areax(self, *args, **kwargs):
`~proplot.wrappers.fill_betweenx_wrapper`."""
return self.fill_betweenx(*args, **kwargs)

def boxes(self, *args, **kwargs):
"""Alias for `~matplotlib.axes.Axes.boxplot`, which is wrapped by
`~proplot.wrappers.boxplot_wrapper`."""
return self.boxplot(*args, **kwargs)

def cmapline(self, *args, values=None,
cmap=None, norm=None,
interp=0, **kwargs):
Expand Down Expand Up @@ -1349,6 +1355,11 @@ def panel_axes(self, side, **kwargs):
"""
return self.figure._add_axes_panel(self, side, **kwargs)

def violins(self, *args, **kwargs):
"""Alias for `~matplotlib.axes.Axes.violinplot`, which is wrapped by
`~proplot.wrappers.violinplot_wrapper`."""
return self.violinplot(*args, **kwargs)

panel = panel_axes
"""Alias for `~Axes.panel_axes`."""
inset = inset_axes
Expand Down Expand Up @@ -2268,8 +2279,8 @@ def __init__(self, *args, **kwargs): # just to disable docstring inheritence

@wrappers._expand_methods_list
def __getattribute__(self, attr, *args):
"""Disables the methods `_map_disabled_methods`, which are inappropriate
for map projections."""
"""Disables the methods `MAP_DISABLED_METHODS`, which are
inappropriate for map projections."""
if attr in wrappers._map_disabled_methods:
raise AttributeError(f'Invalid plotting function {attr!r} for map projection axes.')
return super().__getattribute__(attr, *args)
Expand Down
34 changes: 15 additions & 19 deletions proplot/projs.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ def Proj(name, basemap=False, **kwargs):
# Basemap
if basemap:
import mpl_toolkits.basemap as mbasemap # verify package is available
name = _basemap_cyl.get(name, name)
name = BASEMAP_TRANSLATE.get(name, name)
kwproj = basemap_rc.get(name, {})
kwproj.update(kwargs)
kwproj.setdefault('fix_aspect', True)
if name in _basemap_circles:
if name[:2] in ('np', 'sp'):
kwproj.setdefault('round', True)
if name == 'geos': # fix non-conda installed basemap issue: https://github.com/matplotlib/basemap/issues/361
kwproj.setdefault('rsphere', (6378137.00,6356752.3142))
Expand All @@ -161,7 +161,7 @@ def Proj(name, basemap=False, **kwargs):
# Cartopy
else:
import cartopy.crs as ccrs # verify package is available
kwargs = {_crs_translate.get(key, key): value for key,value in kwargs.items()}
kwargs = {CARTOPY_CRS_TRANSLATE.get(key, key): value for key,value in kwargs.items()}
crs = cartopy_projs.get(name, None)
if name == 'geos': # fix common mistake
kwargs.pop('central_latitude', None)
Expand Down Expand Up @@ -269,15 +269,19 @@ def __init__(self, central_longitude=0.0, globe=None):
super().__init__(central_latitude=-90,
central_longitude=central_longitude, globe=globe)

# Basemap stuff
_basemap_circles = (
'npstere', 'spstere', 'nplaea',
'splaea', 'npaeqd', 'spaeqd',
)
_basemap_cyl = { # aliases for 'cyl', that match PROJ4 name and common name
# Hidden constants
BASEMAP_TRANSLATE = {
'eqc': 'cyl',
'pcarree': 'cyl',
}
CARTOPY_CRS_TRANSLATE = { # add to this
'lat_0': 'central_latitude',
'lon_0': 'central_longitude',
'lat_min': 'min_latitude',
'lat_max': 'max_latitude',
}

# Documented constants
basemap_rc = { # note either llcrn/urcrnr args (all 4) can be specified, or width and height can be specified
'eck4': {'lon_0':0},
'geos': {'lon_0':0},
Expand Down Expand Up @@ -310,13 +314,6 @@ def __init__(self, central_longitude=0.0, globe=None):
`~mpl_toolkits.basemap` will raise an error if you don't provide them,
so ProPlot imposes some sensible default behavior."""

# Cartopy stuff
_crs_translate = { # add to this
'lat_0': 'central_latitude',
'lon_0': 'central_longitude',
'lat_min': 'min_latitude',
'lat_max': 'max_latitude',
}
cartopy_projs = {}
"""Mapping of "projection names" to cartopy `~cartopy.crs.Projection` classes."""
if _cartopy_installed:
Expand Down Expand Up @@ -360,12 +357,12 @@ def __init__(self, central_longitude=0.0, globe=None):
'merc': 'Mercator',
'mill': 'Miller',
'moll': 'Mollweide',
'npstere': 'NorthPolarStereo', # north/south pole stuff not in PROJ.4
'npstere': 'NorthPolarStereo', # np/sp stuff not in PROJ.4
'nsper': 'NearsidePerspective',
'ortho': 'Orthographic',
'osgb': 'OSGB', # UK; not in basemap or PROJ.4
'osni': 'OSNI', # Ireland; not in basemap or PROJ.4
'pcarree': 'PlateCarree', # common alt name
'pcarree': 'PlateCarree', # common alternate name
'robin': 'Robinson',
'rotpole': 'RotatedPole',
'sinu': 'Sinusoidal',
Expand All @@ -381,4 +378,3 @@ def __init__(self, central_longitude=0.0, globe=None):
cartopy_projs[_name] = _class
if _unavail:
warnings.warn(f'Cartopy projection(s) {", ".join(_unavail)} are unavailable. Consider updating to cartopy >= 0.17.0.')

Loading