Add support for sophisticated y-axis information. #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements support for a dynamic y-axis display mechanism. This satisfies SortingView issue #184 (labeling the extrema of the vertical axis in timeseries panels), and lays groundwork for SortingView issue #181 (allowing user-specified y-scale for TimeSeriesView-based visualizations).
It also addresses SpikeSortingView issue #38 (regarding illegible rasterplotview unit IDs) and does a few other housekeeping things (though not enough to satisfy #28 or #32, which will come later).
Features
The y-axis tick marks implement the following features:
Consider a plot drawn with a vertical span of 250 pixels. Grid lines should be spaced between 26 and 60 pixels apart, so we need an integer number of grid lines in the range [5, 9]. Assume the data values run from 91.117656 to 91.125787; the total range displayed in this plot is .008131 units.
We will scale this range to an integer, then compute step sizes of 1, 2, or 5 units at several scales until we find the first step size that creates grids with appropriate spacing. So, 8131/1, 8131/2, 8131/5, 8131/10, [...20, 50, ...] all yield too many grid lines; eventually we find that a step size of 1000 fits in the appropriate range. Resetting the scale, we should span the range from 91.117656 to 91.125787 with eight steps of size 0.001, resulting in grid lines drawn at 91.118, 91.119, 91.120, ... 91.125. The tick at 91.120 is major (as it has a 0 in the thousandths place); the other lines are minor ticks. The resulting graph will label the extrema exactly, but ticks will be labeled while suppressing the repeated higher-order digits, i.e. as 0.118, 0.119, ... 0.125, to highlight the moving scale. (This last feature may potentially be controversial; it can be toggled off easily in code, or we can later implement a user control if it would be useful in limited circumstances.)
Example:
https://www.figurl.org/f?v=http://localhost:3000&d=7086880aeb347d2b2a1f71e2638f7560b67e678e&channel=flatiron1&label=Jaq_03_12_visualization_data2
(Example for 0-based linear position and speed.)
https://www.figurl.org/f?v=http://localhost:3000&d=79f878acca63c2527d2e5d99189852047b5af2c2&channel=flatiron1&label=despereaux20191125_.nwb_02_r1_13_franklab_default_hippocampus
(An individual plot, whose range spans the axis 0.)
(The same example, dynamically rescaled just by removing unit 7, which has an outlier).
Additionally, I have added code to suppress display of the unit labels for the raster plot when there is not sufficient room to write them legibly (currently defined as having 7.2 pixels of space or more).
Implementation
Main changes:
Smaller changes:
SpikeAmplitudesView
andPositionPlotView
component code so that they take advantage of the y-axis logic and can actually display. (It'd be nice to generalize this so it isn't needed for each component--a revision should probably get passed a function that describes how to get the data range from the component's data and lets the baseTimeSeriesView
handle axis computation from that point, rather than having the calling classes use a bunch of logic to set the range externally.PositionPlotView
file, was moved to theTimeSeriesView
class and given an optional parameter which allows the user to override defaults for any of the four margins.TimeSeriesView
component to accommodate for having moved the margin-handling hook.TSVAxesLayer.tsx
has been modified to accept the y-tick data.TimeSeriesView
modified to add some hooks for using transformation matrices to compute the correct position of y-axis labels.Outstanding: