6 May 2011 11:49
Shift by the first value
Hello everyone,
I wrote a very simple dataset plugin which shifts a dataset so that the dataset
starts with 0. Mostly useful to shift a time axis (x axis) that doesn't start
with t=0 at the beginning of the measurement.
Notice that this can be done with builtin features, but it is not as easy:
- define a function "start = lambda x: x[0]", then
- create a new dataset "newdataset = olddataset - start(olddataset)").
------------ plugin start ------------
import veusz.plugins as plugins
class ZeroShiftDatasetPlugin(plugins.DatasetPlugin):
"""Dataset plugin to shift a dataset, so that it starts at 0."""
# tuple of strings to build position on menu
menu = ('Compute', 'Shift by first value...')
# internal name for reusing plugin later
name = 'ZeroShift'
# string which appears in status bar
description_short = 'Shift dataset by its first value'
# string goes in dialog box
description_full = ('Shift a dataset by its first value. '
'The new dataset starts with zero.')
def __init__(self):
(Continue reading)
Jeremy
RSS Feed