Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Replace "panels" with EdgeStack, permit working directly with add_subplot/GridSpec #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 86 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Install shinx extensions
# WARNING: Pip install hangs onto older commits unless __version__ is changed
# since otherwise setup.py will not think it is necessary to rebuild
pyyaml>=5.0.0
numpy>=1.14
ipython>=7.0.0
matplotlib>=3.0
git+https://github.com/lukelbd/[email protected]
10 changes: 8 additions & 2 deletions proplot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#!/usr/bin/env python3
# Import everything into the top-level module namespace
# Make sure to load styletools early so we can try to update TTFPATH before
# the fontManager is loaded by other modules (requiring a rebuild)
# Monkey patch warnings format for warnings issued by ProPlot, make sure to
# detect if this is just a matplotlib warning traced back to ProPlot code by
# testing whether the warned line contains "warnings.warn"
# See: https://stackoverflow.com/a/2187390/4970632
# For internal warning call signature:
# https://docs.python.org/3/library/warnings.html#warnings.showwarning
# For default warning source code see:
# https://github.com/python/cpython/blob/master/Lib/warnings.py
import os as _os
import pkg_resources as _pkg
from .utils import _benchmark
Expand Down
59 changes: 22 additions & 37 deletions proplot/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,13 @@ def _parse_format(mode=2, rc_kw=None, **kwargs):
class Axes(maxes.Axes):
"""Lowest-level axes subclass. Handles titles and axis
sharing. Adds several new methods and overrides existing ones."""
def __init__(self, *args, number=None, main=False, **kwargs):
def __init__(self, *args, number=None, **kwargs):
"""
Parameters
----------
number : int
The subplot number, used for a-b-c labeling. See `~Axes.format`
for details. Note the first axes is ``1``, not ``0``.
main : bool, optional
Used internally, indicates whether this is a "main axes" rather
than a twin, panel, or inset axes.
*args, **kwargs
Passed to `~matplotlib.axes.Axes`.

Expand Down Expand Up @@ -184,8 +181,6 @@ def __init__(self, *args, number=None, main=False, **kwargs):
0.5, 0.95, '', va='bottom', ha='center', transform=coltransform)
self._share_setup()
self.number = number # for abc numbering
if main:
self.figure._axes_main.append(self)
self.format(mode=1) # mode == 1 applies the rcShortParams

def _draw_auto_legends_colorbars(self):
Expand Down Expand Up @@ -357,10 +352,10 @@ def _range_gridspec(self, x):
raise RuntimeError(f'Axes is not a subplot.')
ss = self.get_subplotspec()
if x == 'x':
_, _, _, _, col1, col2 = ss.get_active_rows_columns()
_, _, _, _, col1, col2 = ss.get_rows_columns()
return col1, col2
else:
_, _, row1, row2, _, _ = ss.get_active_rows_columns()
_, _, row1, row2, _, _ = ss.get_rows_columns()
return row1, row2

def _range_tightbbox(self, x):
Expand All @@ -383,6 +378,7 @@ def _reassign_suplabel(self, side):
# Place column and row labels on panels instead of axes -- works when
# this is called on the main axes *or* on the relevant panel itself
# TODO: Mixed figure panels with super labels? How does that work?
# TODO: Remove this when panels implemented as stacks!
s = side[0]
side = SIDE_TRANSLATE[s]
if s == self._panel_side:
Expand Down Expand Up @@ -415,6 +411,7 @@ def _reassign_title(self):
# called on the main axes *or* on the top panel itself. This is
# critical for bounding box calcs; not always clear whether draw() and
# get_tightbbox() are called on the main axes or panel first
# TODO: Remove this when panels implemented as stacks!
if self._panel_side == 'top' and self._panel_parent:
ax, taxs = self._panel_parent, [self]
else:
Expand Down Expand Up @@ -662,8 +659,7 @@ def format(
positioned inside the axes. This can help them stand out on top
of artists plotted inside the axes. Defaults are
:rc:`abc.border` and :rc:`title.border`
ltitle, rtitle, ultitle, uctitle, urtitle, lltitle, lctitle, lrtitle \
: str, optional
ltitle, rtitle, ultitle, uctitle, urtitle, lltitle, lctitle, lrtitle : str, optional
Axes titles in particular positions. This lets you specify multiple
"titles" for each subplots. See the `abcloc` keyword.
top : bool, optional
Expand All @@ -675,8 +671,7 @@ def format(
llabels, tlabels, rlabels, blabels : list of str, optional
Aliases for `leftlabels`, `toplabels`, `rightlabels`,
`bottomlabels`.
leftlabels, toplabels, rightlabels, bottomlabels : list of str, \
optional
leftlabels, toplabels, rightlabels, bottomlabels : list of str, optional
The subplot row and column labels. If list, length must match
the number of subplots on the left, top, right, or bottom edges
of the figure.
Expand All @@ -701,7 +696,7 @@ def format(
:py:obj:`XYAxes.format`,
:py:obj:`ProjAxes.format`,
:py:obj:`PolarAxes.format`,
"""
""" # noqa
# Figure patch (for some reason needs to be re-asserted even if
# declared before figure is drawn)
kw = rc.fill({'facecolor': 'figure.facecolor'}, context=True)
Expand Down Expand Up @@ -908,7 +903,6 @@ def colorbar(
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.
Otherwise, the default is :rc:`subplots.panelpad`.
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 @@ -947,34 +941,30 @@ def colorbar(
self.patch.set_alpha(0)
self._panel_filled = True

# Draw colorbar with arbitrary length relative to full length
# of panel
# Draw colorbar with arbitrary length relative to full panel length
# TODO: Can completely remove references to GridSpecFromSubplotSpec
# if implement colorbars as "parasite" objects instead.
side = self._panel_side
length = _notNone(length, rc['colorbar.length'])
subplotspec = self.get_subplotspec()
ss = self.get_subplotspec()
if length <= 0 or length > 1:
raise ValueError(
f'Panel colorbar length must satisfy 0 < length <= 1, '
f'got length={length!r}.'
)
if side in ('bottom', 'top'):
gridspec = mgridspec.GridSpecFromSubplotSpec(
gs = mgridspec.GridSpecFromSubplotSpec(
nrows=1, ncols=3, wspace=0,
subplot_spec=subplotspec,
subplot_spec=ss,
width_ratios=((1 - length) / 2, length, (1 - length) / 2),
)
subplotspec = gridspec[1]
else:
gridspec = mgridspec.GridSpecFromSubplotSpec(
gs = mgridspec.GridSpecFromSubplotSpec(
nrows=3, ncols=1, hspace=0,
subplot_spec=subplotspec,
subplot_spec=ss,
height_ratios=((1 - length) / 2, length, (1 - length) / 2),
)
subplotspec = gridspec[1]
with self.figure._authorize_add_subplot():
ax = self.figure.add_subplot(subplotspec, projection=None)
if ax is self:
raise ValueError # should never happen
ax = self.figure.add_subplot(gs[1], main=False, projection=None)
self.add_child_axes(ax)

# Location
Expand Down Expand Up @@ -1150,7 +1140,6 @@ 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.
Otherwise, the default is :rc:`subplots.panelpad`.

Other parameters
----------------
Expand Down Expand Up @@ -1250,8 +1239,7 @@ def inset_axes(
----------
bounds : list of float
The bounds for the inset axes, listed as ``(x, y, width, height)``.
transform : {'data', 'axes', 'figure'} or \
`~matplotlib.transforms.Transform`, optional
transform : {'data', 'axes', 'figure'} or `~matplotlib.transforms.Transform`, optional
The transform used to interpret `bounds`. Can be a
`~matplotlib.transforms.Transform` object or a string representing
the `~matplotlib.axes.Axes.transData`,
Expand All @@ -1275,7 +1263,7 @@ def inset_axes(
----------------
**kwargs
Passed to `XYAxes`.
"""
""" # noqa
# Carbon copy with my custom axes
if not transform:
transform = self.transAxes
Expand Down Expand Up @@ -1379,7 +1367,6 @@ 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, the default is :rc:`subplots.panelpad`.
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 @@ -2628,8 +2615,7 @@ def altx(self, **kwargs):
# See https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes/_subplots.py # noqa
if self._altx_child or self._altx_parent:
raise RuntimeError('No more than *two* twin axes are allowed.')
with self.figure._authorize_add_subplot():
ax = self._make_twin_axes(sharey=self, projection='xy')
ax = self._make_twin_axes(sharey=self, projection='xy')
ax.set_autoscaley_on(self.get_autoscaley_on())
ax.grid(False)
self._altx_child = ax
Expand All @@ -2645,8 +2631,7 @@ def alty(self, **kwargs):
"""Docstring is replaced below."""
if self._alty_child or self._alty_parent:
raise RuntimeError('No more than *two* twin axes are allowed.')
with self.figure._authorize_add_subplot():
ax = self._make_twin_axes(sharex=self, projection='xy')
ax = self._make_twin_axes(sharex=self, projection='xy')
ax.set_autoscalex_on(self.get_autoscalex_on())
ax.grid(False)
self._alty_child = ax
Expand Down Expand Up @@ -3737,7 +3722,7 @@ def _format_apply(
p.set_clip_on(False) # so edges denoting boundary aren't cut off
self._map_boundary = p
else:
self.patch.update({**kw_face, 'edgecolor': 'none'})
self.patch.update(edgecolor='none', **kw_face)
for spine in self.spines.values():
spine.update(kw_edge)

Expand Down
1 change: 0 additions & 1 deletion proplot/axistools.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,6 @@ def __init__(
axis scales like `~proplot.axistools.LogScale`. We try to correct
this behavior with a patch.
"""
tickrange = tickrange or (-np.inf, np.inf)
super().__init__(*args, **kwargs)
zerotrim = _notNone(zerotrim, rc['axes.formatter.zerotrim'])
self._zerotrim = zerotrim
Expand Down
2 changes: 1 addition & 1 deletion proplot/external/hsluv.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* `rgb_to_hsluv`
* `hpluv_to_rgb`
* `rgb_to_hpluv`
"""
""" # noqa
# Imports (below functions are just meant to be used by user)
# See: https://stackoverflow.com/a/2353265/4970632
# The HLS is actually HCL
Expand Down
5 changes: 3 additions & 2 deletions proplot/styletools.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ class LinearSegmentedColormap(mcolors.LinearSegmentedColormap, _Colormap):
r"""
New base class for all `~matplotlib.colors.LinearSegmentedColormap`\ s.
"""

def __str__(self):
return type(self).__name__ + f'(name={self.name!r})'

Expand Down Expand Up @@ -1269,6 +1270,7 @@ class ListedColormap(mcolors.ListedColormap, _Colormap):
r"""
New base class for all `~matplotlib.colors.ListedColormap`\ s.
"""

def __str__(self):
return f'ListedColormap(name={self.name!r})'

Expand Down Expand Up @@ -1532,7 +1534,6 @@ def __init__(
... 'luminance': [[0, 100, 100], [1, 20, 20]],
... }
>>> cmap = plot.PerceptuallyUniformColormap(data)

"""
# Checks
space = _notNone(space, 'hsl').lower()
Expand Down Expand Up @@ -2519,7 +2520,6 @@ class BinNorm(mcolors.BoundaryNorm):
`norm` is compared against the normalized `levels` array. Its bin index
is determined with `numpy.searchsorted`, and its corresponding
colormap coordinate is selected using this index.

"""
# See this post: https://stackoverflow.com/a/48614231/4970632
# WARNING: Must be child of BoundaryNorm. Many methods in ColorBarBase
Expand Down Expand Up @@ -2666,6 +2666,7 @@ class LinearSegmentedNorm(mcolors.Normalize):
Can be used by passing ``norm='segmented'`` or ``norm='segments'`` to any
command accepting ``cmap``. The default midpoint is zero.
"""

def __init__(self, levels, vmin=None, vmax=None, **kwargs):
"""
Parameters
Expand Down
Loading