Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
castillohair committed Mar 3, 2017
2 parents 9696171 + 5202f70 commit cf42552
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
2 changes: 1 addition & 1 deletion FlowCal/__init__.py
Expand Up @@ -6,7 +6,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
__version__ = '1.1.1'
__version__ = '1.1.2'

import io
import excel_ui
Expand Down
67 changes: 66 additions & 1 deletion FlowCal/plot.py
Expand Up @@ -380,7 +380,7 @@ def inverted(self):
smin=0,
smax=self._M)

class _LogicleLocator(matplotlib.ticker.SymmetricalLogLocator):
class _LogicleLocator(matplotlib.ticker.Locator):
"""
Determine the tick locations for logicle axes.
Expand All @@ -394,6 +394,40 @@ class _LogicleLocator(matplotlib.ticker.SymmetricalLogLocator):
"""

def __init__(self, transform, subs=None):
self._transform = transform
if subs is None:
self._subs = [1.0]
else:
self._subs = subs
self.numticks = 15

def set_params(self, subs=None, numticks=None):
"""
Set parameters within this locator.
Parameters
----------
subs : array, optional
Subtick values, as multiples of the main ticks.
numticks : array, optional
Number of ticks.
"""
if numticks is not None:
self.numticks = numticks
if subs is not None:
self._subs = subs

def __call__(self):
"""
Return the locations of the ticks.
"""
# Note, these are untransformed coordinates
vmin, vmax = self.axis.get_view_interval()
return self.tick_values(vmin, vmax)

def tick_values(self, vmin, vmax):
"""
Get a set of tick values properly spaced for logicle axis.
Expand Down Expand Up @@ -483,6 +517,37 @@ def tick_values(self, vmin, vmax):

return self.raise_if_exceeds(np.array(ticklocs))


def view_limits(self, vmin, vmax):
"""
Try to choose the view limits intelligently.
"""
b = self._transform.base
if vmax < vmin:
vmin, vmax = vmax, vmin

if not matplotlib.ticker.is_decade(abs(vmin), b):
if vmin < 0:
vmin = -matplotlib.ticker.decade_up(-vmin, b)
else:
vmin = matplotlib.ticker.decade_down(vmin, b)
if not matplotlib.ticker.is_decade(abs(vmax), b):
if vmax < 0:
vmax = -matplotlib.ticker.decade_down(-vmax, b)
else:
vmax = matplotlib.ticker.decade_up(vmax, b)

if vmin == vmax:
if vmin < 0:
vmin = -matplotlib.ticker.decade_up(-vmin, b)
vmax = -matplotlib.ticker.decade_down(-vmax, b)
else:
vmin = matplotlib.ticker.decade_down(vmin, b)
vmax = matplotlib.ticker.decade_up(vmax, b)
result = matplotlib.transforms.nonsingular(vmin, vmax)
return result

class _LogicleScale(matplotlib.scale.ScaleBase):
"""
Class that implements the logicle axis scaling.
Expand Down

0 comments on commit cf42552

Please sign in to comment.