Skip to content
Closed
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
Respect vmin and vmax as hard minimum/maximum
  • Loading branch information
lukelbd committed Sep 2, 2019
commit a3ebbb12e75a2a110d8d40c20ff0a41b89addf7c
100 changes: 52 additions & 48 deletions proplot/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1672,11 +1672,13 @@ def cmap_wrapper(self, func, *args, cmap=None, cmap_kw=None,
levels are inferred using `~proplot.utils.edges`. This will override
any `levels` input.
vmin, vmax : float, optional
Used to determine level locations if `levels` is an integer and at
least one of `vmin` and `vmax` is provided. The levels will be
``np.linspace(vmin, vmax, levels)``. If `vmin` was omitted but `vmax`
was provided, `vmin` is the data minimum. If `vmax` was omitted but
`vmin` was provided, `vmax` is the data maximum.
Used to determine level locations if `levels` is an integer. Actual
levels may not fall exactly on `vmin` and `vmax`, but the minimum
level will be no smaller than `vmin` and the maximum level will be
no larger than `vmax.

If `vmin` or `vmax` is not provided, the minimum and maximum data
values are used.
locator : locator-spec, optional
The locator used to determine level locations if `levels` or `values`
is an integer and `vmin` and `vmax` were not provided. Passed to the
Expand Down Expand Up @@ -1859,54 +1861,56 @@ def cmap_wrapper(self, func, *args, cmap=None, cmap_kw=None,
# TODO: Add kernel density plot to hexbin!
levels = _notNone(N, levels, rc['image.levels'], names=('N', 'levels'))
if isinstance(levels, Number):
# Cannot infer counts a priori, so do nothing
if name in ('hexbin',):
levels = None # cannot infer *counts*, so do nothing
levels = None
# Use the locator to determine levels
# Mostly copied from the hidden contour.ContourSet._autolev
else:
# Set levels according to vmin and vmax
# Get the locator
N = levels
if vmin is not None or vmax is not None:
vmin = _notNone(vmin, zmin)
vmax = _notNone(vmax, zmax)
levels = np.linspace(vmin, vmax, N)
# Use the locator to determine levels
# Mostly copied from the hidden contour.ContourSet._autolev
if locator is not None:
locator = axistools.Locator(locator, **locator_kw)
elif isinstance(norm, mcolors.LogNorm):
locator = mticker.LogLocator(**locator_kw)
else:
# Get and apply the locator
if locator is not None:
locator = axistools.Locator(locator, **locator_kw)
elif isinstance(norm, mcolors.LogNorm):
locator = mticker.LogLocator(**locator_kw)
else:
locator_kw = {**locator_kw}
locator_kw.setdefault('symmetric', symmetric)
locator = mticker.MaxNLocator(N, min_n_ticks=1, **locator_kw)
try:
levels = locator.tick_values(zmin, zmax)
except RuntimeError:
levels = np.linspace(zmin, zmax, N) # TODO: orig used N+1
# Trim excess levels the locator may have supplied.
if not locator_kw.get('symmetric', None):
under, = np.where(levels < zmin)
i0 = under[-1] if len(under) else 0
over, = np.where(levels > zmax)
locator_kw = {**locator_kw}
locator_kw.setdefault('symmetric', symmetric)
locator = mticker.MaxNLocator(N, min_n_ticks=1, **locator_kw)
# Get locations
hardmin, hardmax = (vmin is not None), (vmax is not None)
vmin = _notNone(vmin, zmin)
vmax = _notNone(vmax, zmax)
try:
levels = locator.tick_values(vmin, vmax)
except RuntimeError:
levels = np.linspace(vmin, vmax, N) # TODO: orig used N+1
# Trim excess levels the locator may have supplied
if not locator_kw.get('symmetric', None):
i0, i1 = 0, len(levels) # defaults
under, = np.where(levels < vmin)
if len(under):
i0 = under[-1]
if hardmin or extend in ('min', 'both'):
i0 += 1 # permit out-of-bounds data
over, = np.where(levels > vmax)
if len(over):
i1 = over[0] + 1 if len(over) else len(levels)
if extend in ('min', 'both'):
i0 += 1
if extend in ('max', 'both'):
i1 -= 1
if i1 - i0 < 3:
i0, i1 = 0, len(levels)
levels = levels[i0:i1]
# Special consideration if not enough levels
nn = N//len(levels) # how many times more levels did we want than what we got?
if nn >= 2:
olevels = norm(levels)
nlevels = []
for i in range(len(levels)-1):
l1, l2 = olevels[i], olevels[i+1]
nlevels.extend(np.linspace(l1, l2, nn+1)[:-1])
nlevels.append(olevels[-1])
levels = norm.inverse(nlevels)
if hardmax or extend in ('max', 'both'):
i1 -= 1 # permit out-of-bounds data
if i1 - i0 < 3:
i0, i1 = 0, len(levels) # revert
levels = levels[i0:i1]
# Special consideration if not enough levels
nn = N//len(levels) # how many times more levels did we want than what we got?
if nn >= 2:
olevels = norm(levels)
nlevels = []
for i in range(len(levels)-1):
l1, l2 = olevels[i], olevels[i+1]
nlevels.extend(np.linspace(l1, l2, nn+1)[:-1])
nlevels.append(olevels[-1])
levels = norm.inverse(nlevels)

# Norm settings
# Generate BinNorm, and update child norm object with vmin and vmax from levels
Expand Down