#!/usr/bin/env python\r
+# -*- coding: utf-8 -*-\r
\r
'''\r
HOOKE - A force spectroscopy review & analysis tool\r
self.figures=[control.get_figure() for control in self.controls]\r
self.axes=[figure.gca() for figure in self.figures]\r
\r
+ for i in range(len(self.axes)):\r
+ self.axes[i].xaxis.set_major_formatter(EngrFormatter())\r
+ self.axes[i].yaxis.set_major_formatter(EngrFormatter(2))\r
+\r
+\r
self.cpanels[1].Hide()\r
self.mainpanel.splitter.Initialize(self.cpanels[0])\r
\r
ylim=self.axes[dest].get_ylim() \r
self.axes[dest].set_ylim((ylim[1],ylim[0])) \r
\r
+ for i in range(len(self.axes)):\r
+ self.axes[i].xaxis.set_major_formatter(EngrFormatter())\r
+ self.axes[i].yaxis.set_major_formatter(EngrFormatter(2))\r
+\r
+\r
self.controls[dest].draw()\r
\r
\r
#!/usr/bin/env python
+# -*- coding: utf-8 -*-
'''
libhooke.py
import os
import string
import csv
+from matplotlib.ticker import ScalarFormatter
+
HOOKE_VERSION=['0.8.3_devel', 'Seinei', '2008-04-16']
WX_GOOD=['2.6','2.8']
pass
+class EngrFormatter(ScalarFormatter):
+ """A variation of the standard ScalarFormatter, using only multiples of
+three
+in the mantissa. A fixed number of decimals can be displayed with the optional
+parameter `ndec` . If `ndec` is None (default), the number of decimals is
+defined
+from the current ticks.
+ """
+ def __init__(self, ndec=None, useOffset=True, useMathText=False):
+ ScalarFormatter.__init__(self, useOffset, useMathText)
+ if ndec is None or ndec < 0:
+ self.format = None
+ elif ndec == 0:
+ self.format = "%d"
+ else:
+ self.format = "%%1.%if" % ndec
+ #........................
+
+ def _set_orderOfMagnitude(self, mrange):
+ """Sets the order of magnitude."""
+ locs = numpy.absolute(self.locs)
+ if self.offset:
+ oom = numpy.floor(numpy.log10(mrange))
+ else:
+ if locs[0] > locs[-1]:
+ val = locs[-1]
+ else:
+ val = locs[0]
+ if val == 0:
+ oom = 0
+ else:
+ oom = numpy.floor(numpy.log10(val))
+ if oom <= -3:
+ self.orderOfMagnitude = 3*(oom//3)
+ elif oom <= -1:
+ self.orderOfMagnitude = -3
+ elif oom >= 4:
+ self.orderOfMagnitude = 3*(oom//3)
+ else:
+ self.orderOfMagnitude = 0
+
+
+ #........................
+ def _set_format(self):
+ """Sets the format string to format all ticklabels."""
+ # set the format string to format all the ticklabels
+ locs = (numpy.array(self.locs)-self.offset) / 10**self.orderOfMagnitude+1e-15
+ sigfigs = [len(str('%1.3f'% loc).split('.')[1].rstrip('0')) \
+ for loc in locs]
+ sigfigs.sort()
+ if self.format is None:
+ self.format = '%1.' + str(sigfigs[-1]) + 'f'
+ if self._usetex or self._useMathText: self.format = '$%s$'%self.format
+
+
+
class ClickedPoint:
'''
this class defines what a clicked point on the curve plot is