Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
fc9a23d
Process projection args in add_subplot and ensure matching geometry
lukelbd Sep 18, 2019
0bbcfc4
Remove projection processing from subplots(), update add_subplot() docs
lukelbd Sep 18, 2019
7c9419d
Update Proj, no longer returns aspect becuase that is fixed automatic…
lukelbd Sep 18, 2019
91d46cf
Merge branch 'master' into allow-add-subplot
lukelbd Sep 29, 2019
e669482
Rename FlexibleGridSpec --> GridSpec (like Axes + Figure), update dev…
lukelbd Sep 29, 2019
7dd3b3a
Add figure_kwargs to docstring.interpd
lukelbd Sep 29, 2019
fe8607a
Fix add_subplot docstring
lukelbd Sep 29, 2019
78aafb1
Merge branch 'master' into allow-add-subplot
lukelbd Oct 31, 2019
5a3b13c
Merge branch 'master' into allow-add-subplot
lukelbd Oct 31, 2019
78e454b
Merge branch 'master' into allow-add-subplot
lukelbd Oct 31, 2019
08f5cbb
Colormap() converts input matplotlib cmaps to subclass
lukelbd Oct 31, 2019
0bcf8a9
GridSpec tracks figures automatically, fix add_subplot bugs
lukelbd Oct 31, 2019
81e40a5
Misc bugfixes
lukelbd Oct 31, 2019
3ae4f2b
Remove unlocker, move Axes 'main' kwarg to add_subplot
lukelbd Oct 31, 2019
dcd918e
Rename hidden func
lukelbd Oct 31, 2019
fbe0a5d
Merge branch 'master' into allow-add-subplot
lukelbd Oct 31, 2019
baf04d5
Docs cleanup, axes number, misc minor changes
lukelbd Oct 31, 2019
c2519f6
Implement _subplots_geometry as Figure method, major refactor
lukelbd Oct 31, 2019
f30e25f
Merge branch 'master' into allow-add-subplot
lukelbd Oct 31, 2019
106f00b
Fix GridSpec docs
lukelbd Nov 1, 2019
7792b30
Merge branch 'master' into allow-add-subplot
lukelbd Nov 1, 2019
707d377
Let Proj accept objects, misc minor changes
lukelbd Nov 4, 2019
05b1f7a
Massive overhaul of rctools, related changes
lukelbd Nov 4, 2019
79e5ce6
Fix import errors and remove proplotrc
lukelbd Nov 4, 2019
b87ec25
Considerably simplify rc.contex, use cache only with get(), fill(), c…
lukelbd Nov 4, 2019
1d300b5
rc cleanup, more accurate default spacing when tight=False
lukelbd Nov 5, 2019
7ae38c5
Major GridSpec refactor, make share/span/align figure-wide, altx/y fixes
lukelbd Nov 5, 2019
3dd5222
New geometry_configurator class, incomplete
lukelbd Nov 6, 2019
4ef57fa
Make rc.get/fill/category 'context' keyword only
lukelbd Nov 6, 2019
3205443
Misc cleanup, add EdgeStack class
lukelbd Nov 10, 2019
5a05059
Fix colormap merge conflict
lukelbd Nov 11, 2019
7cc81a0
Imperative mood for all docstrings
lukelbd Nov 11, 2019
fd386f0
New show_cycles, cleanup and benchmarking changes
lukelbd Nov 13, 2019
1e488a7
Add tickminor global setting
lukelbd Nov 15, 2019
cd23f3f
Use standard library for xml parsing
lukelbd Nov 16, 2019
d347507
Stashed changes
lukelbd Nov 17, 2019
d5c1199
Add from_file staticmethods
lukelbd Nov 19, 2019
7f278a5
Fix ginormous merge conflict
lukelbd Nov 27, 2019
3f33936
Merge from master
lukelbd Nov 28, 2019
88af384
Organize projs
lukelbd Nov 28, 2019
689d33b
Merge branch 'master' into allow-add-subplot
lukelbd Nov 29, 2019
b4df874
Pep8 compliance
lukelbd Nov 30, 2019
d642f85
Merge branch 'master' into allow-add-subplot
lukelbd Nov 30, 2019
2ec9ed2
Merge branch 'master' into allow-add-subplot
lukelbd Nov 30, 2019
67167f6
Fix conflicts
lukelbd Dec 2, 2019
1227574
Merge from master
lukelbd Dec 2, 2019
2803a8e
Merge from master
lukelbd Dec 2, 2019
9feca72
Merge branch 'master' into allow-add-subplot
lukelbd Dec 2, 2019
ff8793e
Fix RST hyperlinks
lukelbd Dec 2, 2019
6956aaf
Merge branch 'master' into allow-add-subplot
lukelbd Dec 2, 2019
956d1c8
Remove _hidelabels
lukelbd Dec 6, 2019
41cfc64
Merge from master
lukelbd Dec 7, 2019
14a9975
Minor merge
lukelbd Dec 7, 2019
8ee42bd
Fix conflicts
lukelbd Dec 8, 2019
92d0ab2
Merge from master
lukelbd Dec 8, 2019
c44f7b0
Merge branch 'master' into allow-add-subplot
lukelbd Dec 8, 2019
9816145
Add xgridcolor/ygridcolor
lukelbd Dec 8, 2019
6a768fe
Merge branch 'master' into allow-add-subplot
lukelbd Dec 8, 2019
fe06c38
Merge from master
lukelbd Dec 8, 2019
2980023
Fix rc bugs, remove system proplotrc
lukelbd Dec 8, 2019
bceca60
Merge branch 'master' into allow-add-subplot
lukelbd Dec 8, 2019
92b4c46
Merge branch 'master' into allow-add-subplot
lukelbd Dec 8, 2019
d57a2c8
Merge from master
lukelbd Dec 9, 2019
88648ee
Merge branch 'master' into allow-add-subplot
lukelbd Dec 9, 2019
5995763
Merge from master
lukelbd Dec 9, 2019
2928e2b
Merge from master
lukelbd Dec 9, 2019
50c6906
Merge from master
lukelbd Dec 12, 2019
f2f49f9
Merge from master
lukelbd Dec 13, 2019
55ccce3
Merge from master
lukelbd Dec 13, 2019
6154471
Merge branch 'master' into allow-add-subplot
lukelbd Dec 13, 2019
62483bd
Merge from master
lukelbd Dec 14, 2019
4ae0aba
Merge from master
lukelbd Dec 14, 2019
0afcb34
Merge from master
lukelbd Dec 16, 2019
29e8b6b
Merge from master
lukelbd Jan 6, 2020
bf03212
Merge from master
lukelbd Jan 6, 2020
c701a71
Merge from master
lukelbd Jan 6, 2020
7094622
Merge branch 'master' into allow-add-subplot
lukelbd Jan 6, 2020
a96ddf0
Test commit
lukelbd Jan 6, 2020
ee7a836
Merge branch 'master' into allow-add-subplot
lukelbd Jan 6, 2020
f7ee50f
Merge branch 'master' into allow-add-subplot
lukelbd Jan 7, 2020
f535560
Merge branch 'master' into allow-add-subplot
lukelbd Jan 7, 2020
01fa6e5
Merge branch 'master' into allow-add-subplot
lukelbd Jan 7, 2020
8df17f8
Merge branch 'master' into allow-add-subplot
lukelbd Jan 7, 2020
9499d3d
Merge branch 'master' into allow-add-subplot
lukelbd Jan 7, 2020
b366427
Merge branch 'master' into allow-add-subplot
lukelbd Jan 7, 2020
2dd5596
Merge branch 'master' into allow-add-subplot
lukelbd Jan 19, 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
Merge branch 'master' into allow-add-subplot
  • Loading branch information
lukelbd committed Jan 7, 2020
commit 9499d3d71424fc9d8edea9b9e540c6d6f8f8b08d
14 changes: 7 additions & 7 deletions proplot/axistools.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ def get_transform(self):

class LinearScale(_ScaleBase, mscale.LinearScale):
"""
As with `~matplotlib.scale.LinearScale`. `AutoFormatter` is the new
As with `~matplotlib.scale.LinearScale` but with `AutoFormatter` as the
default major formatter.
"""
name = 'linear'
Expand All @@ -656,7 +656,7 @@ def __init__(self, **kwargs):

class LogitScale(_ScaleBase, mscale.LogitScale):
"""
As with `~matplotlib.scale.LogitScale`. `AutoFormatter` is the new
As with `~matplotlib.scale.LogitScale` but with `AutoFormatter` as the
default major formatter.
"""
name = 'logit'
Expand All @@ -678,8 +678,8 @@ def __init__(self, **kwargs):

class LogScale(_ScaleBase, mscale.LogScale):
"""
As with `~matplotlib.scale.LogScale`. `AutoFormatter` is the new
default major formatter. Separate "``x``" and "``y``" versions of each
As with `~matplotlib.scale.LogScale` but with `AutoFormatter` as the
default major formatter. Also, "``x``" and "``y``" versions of each
keyword argument are no longer required.
"""
name = 'log'
Expand Down Expand Up @@ -714,7 +714,7 @@ def __init__(self, **kwargs):
class SymmetricalLogScale(_ScaleBase, mscale.SymmetricalLogScale):
"""
As with `~matplotlib.scale.SymmetricLogScale`. `AutoFormatter` is the new
default major formatter. Separate "``x``" and "``y``" versions of each
default major formatter. Also, "``x``" and "``y``" versions of each
keyword argument are no longer required.
"""
name = 'symlog'
Expand Down Expand Up @@ -1181,7 +1181,7 @@ class SineLatitudeScale(_ScaleBase, mscale.ScaleBase):
r"""
Axis scale that is linear in the *sine* of *x*. The axis limits are
constrained to fall between ``-90`` and ``+90`` degrees. The scale
function is as follows.
function is as follows:

.. math::

Expand Down Expand Up @@ -1363,7 +1363,7 @@ def transform_non_affine(self, a):
class InverseScale(_ScaleBase, mscale.ScaleBase):
r"""
Axis scale that is linear in the *inverse* of *x*. The forward and inverse
scale functions are as follows.
scale functions are as follows:

.. math::

Expand Down
48 changes: 8 additions & 40 deletions proplot/projs.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,12 @@ def Proj(name, basemap=False, **kwargs):
if ((CRS is not object and isinstance(name, CRS))
or (Basemap is not object and isinstance(name, Basemap))):
proj = name
elif not isinstance(proj, str):
elif not isinstance(name, str):
raise ValueError(
f'Unexpected Proj() argument {proj!r}. '
f'Unexpected Proj() argument {name!r}. '
'Must be name, mpl_toolkits.basemap.Basemap instance, '
'or cartopy.crs.CRS instance.')
'or cartopy.crs.CRS instance.'
)
# Basemap
elif basemap:
import mpl_toolkits.basemap as mbasemap
Expand Down Expand Up @@ -194,41 +195,6 @@ class Aitoff(_WarpedRectangularProjection):
"""The `Aitoff <https://en.wikipedia.org/wiki/Aitoff_projection>`__
projection."""
#: Registered projection name.
name = 'hammer'

def __init__(self, central_longitude=0, globe=None,
false_easting=None, false_northing=None):
from cartopy._crs import Globe
from cartopy.crs import WGS84_SEMIMAJOR_AXIS
if globe is None:
globe = Globe(semimajor_axis=WGS84_SEMIMAJOR_AXIS, ellipse=None)

a = globe.semimajor_axis or WGS84_SEMIMAJOR_AXIS
b = globe.semiminor_axis or a
if b != a or globe.ellipse is not None:
_warn_proplot(
f'The {self.name!r} projection does not handle '
'elliptical globes.'
)

proj4_params = {'proj': 'hammer', 'lon_0': central_longitude}
super().__init__(proj4_params, central_longitude,
false_easting=false_easting,
false_northing=false_northing,
globe=globe)

@property
def threshold(self): # how finely to interpolate line data, etc.
return 1e5

__init__.__doc__ = _proj_doc
threshold.__doc__ = _reso_doc


class Hammer(_WarpedRectangularProjection):
"""The `Hammer <https://en.wikipedia.org/wiki/Hammer_projection>`__
projection."""
#: Registered projection name.
name = 'aitoff'

def __init__(self, central_longitude=0, globe=None,
Expand Down Expand Up @@ -392,8 +358,10 @@ def __init__(self, central_longitude=0.0, globe=None):
class NorthPolarLambertAzimuthalEqualArea(LambertAzimuthalEqualArea):
"""Analogous to `~cartopy.crs.NorthPolarStereo`."""
def __init__(self, central_longitude=0.0, globe=None):
super().__init__(central_latitude=90,
central_longitude=central_longitude, globe=globe)
super().__init__(
central_latitude=90,
central_longitude=central_longitude, globe=globe
)
__init__.__doc__ = _proj_doc


Expand Down
68 changes: 19 additions & 49 deletions proplot/subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,12 @@ def __repr__(self): # do not show width and height ratios
nrows, ncols = self.get_geometry()
return f'GridSpec({nrows}, {ncols})'

def __init__(self, nrows=1, ncols=1,
left=None, right=None, bottom=None, top=None,
wspace=None, hspace=None, wratios=None, hratios=None,
width_ratios=None, height_ratios=None):
def __init__(
self, nrows=1, ncols=1,
left=None, right=None, bottom=None, top=None,
wspace=None, hspace=None, wratios=None, hratios=None,
width_ratios=None, height_ratios=None
):
"""
Parameters
----------
Expand Down Expand Up @@ -1638,7 +1640,7 @@ def _add_figure_panel(

def _get_align_coord(self, side, axs):
"""Return the figure coordinate for spanning labels and super titles.
The `x` can be ``'x'`` or ``'y'``."""
"""
# Get position in figure relative coordinates
s = side[0]
x = ('y' if s in 'lr' else 'x')
Expand Down Expand Up @@ -1846,7 +1848,7 @@ def _update_figtitle(self, title, **kwargs):

def _update_labels(self, ax, side, labels, **kwargs):
"""Assign side labels and updates label settings. The labels are
aligned down the line by geometry_configurators."""
aligned down the line by geometry_configurator."""
s = side[0]
if s not in 'lrbt':
raise ValueError(f'Invalid label side {side!r}.')
Expand Down Expand Up @@ -2339,42 +2341,6 @@ def ref(self, ref):
self.stale = True
self._ref = ref

def set_size_inches(self, w, h=None, forward=True, auto=False):
# Set the figure size and, if this is being called manually or from
# an interactive backend, override the geometry tracker so users can
# use interactive backends. See #76. Undocumented because this is
# only relevant internally.
# NOTE: Bitmap renderers use int(Figure.bbox.[width|height]) which
# rounds to whole pixels. So when renderer resizes the figure
# internally there may be roundoff error! Always compare to *both*
# Figure.get_size_inches() and the truncated bbox dimensions times dpi.
# Comparison is critical because most renderers call set_size_inches()
# before any resizing interaction!
if h is None:
width, height = w
else:
width, height = w, h
if not all(np.isfinite(_) for _ in (width, height)):
raise ValueError(
'Figure size must be finite, not ({width}, {height}).'
)
width_true, height_true = self.get_size_inches()
width_trunc = int(self.bbox.width) / self.dpi
height_trunc = int(self.bbox.height) / self.dpi
if auto:
with self._context_resizing():
super().set_size_inches(width, height, forward=forward)
else:
if ( # can have internal resizing not associated with any draws
(width not in (width_true, width_trunc)
or height not in (height_true, height_trunc))
and not self._is_resizing
and not self.canvas._is_idle_drawing # standard
and not getattr(self.canvas, '_draw_pending', None) # pyqt5
):
self._subplots_kw.update(width=width, height=height)
super().set_size_inches(width, height, forward=forward)

# Add documentation
add_gridspec.__doc__ = _gridspec_doc
set_gridspec.__doc__ = _gridspec_doc
Expand Down Expand Up @@ -2467,9 +2433,9 @@ def subplots(
basemap=False, **kwargs
):
"""
Create a figure with a single axes or arbitrary grid of axes, analogous
to `matplotlib.pyplot.subplots`. The axes can have arbitrary map
projections.
Create a figure with a single subplot or arbitrary grids of subplots,
analogous to `matplotlib.pyplot.subplots`. The subplots can be drawn with
arbitrary projections.

Parameters
----------
Expand Down Expand Up @@ -2588,10 +2554,14 @@ def subplots(
basemap = _axes_dict(naxs, basemap, kw=False, default=False)

# Standardized user input ratios
wratios = np.atleast_1d(_notNone(width_ratios, wratios, 1,
names=('width_ratios', 'wratios')))
hratios = np.atleast_1d(_notNone(height_ratios, hratios, 1,
names=('height_ratios', 'hratios')))
wratios = np.atleast_1d(_notNone(
width_ratios, wratios, 1,
names=('width_ratios', 'wratios')
))
hratios = np.atleast_1d(_notNone(
height_ratios, hratios, 1,
names=('height_ratios', 'hratios')
))
if len(wratios) == 1:
wratios = np.repeat(wratios, (ncols,))
if len(hratios) == 1:
Expand Down
8 changes: 5 additions & 3 deletions proplot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
__all__ = ['arange', 'edges', 'edges2d', 'units']
NUMBER = re.compile('^([-+]?[0-9._]+([eE][-+]?[0-9_]+)?)(.*)$')
BENCHMARK = False # change this to turn on benchmarking
NUMBER = re.compile('^([-+]?[0-9._]+([eE][-+]?[0-9_]+)?)(.*)$')


class _benchmark(object):
Expand Down Expand Up @@ -180,7 +179,8 @@ def edges(Z, axis=-1):
Parameters
----------
Z : array-like
Array of any shape or size.
Array of any shape or size. Generally, should be monotonically
increasing or decreasing along `axis`.
axis : int, optional
The axis along which "edges" are calculated. The size of this axis
will be increased by one.
Expand All @@ -190,6 +190,7 @@ def edges(Z, axis=-1):
`~numpy.ndarray`
Array of "edge" coordinates.
"""
Z = np.asarray(Z)
Z = np.swapaxes(Z, axis, -1)
Z = np.concatenate((
Z[..., :1] - (Z[..., 1] - Z[..., 0]) / 2,
Expand Down Expand Up @@ -223,7 +224,8 @@ def edges2d(Z):
Zb = np.zeros((ny + 1, nx + 1))
# Inner
Zb[1:-1, 1:-1] = 0.25 * (
Z[1:, 1:] + Z[:-1, 1:] + Z[1:, :-1] + Z[:-1, :-1])
Z[1:, 1:] + Z[:-1, 1:] + Z[1:, :-1] + Z[:-1, :-1]
)
# Lower and upper
Zb[0] += edges(1.5 * Z[0] - 0.5 * Z[1])
Zb[-1] += edges(1.5 * Z[-1] - 0.5 * Z[-2])
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.