HoloViews elements like the
Scatter points illustrated in the Introduction contain two types of information:
Your data, in as close to its original form as possible, so that it can be analyzed and accessed as you see fit.
Metadata specifying what your data is, which allows HoloViews to construct an appropriate visual representation for it.
What elements do not contain is:
The endless details that one might want to tweak about the visual representation, such as line widths, colors, fonts, and spacing.
HoloViews is designed to let you work naturally with the meaningful features of your data, while making it simple to adjust the display details separately using the Options system. Among many other benefits, this separation of content from presentation simplifies your data analysis workflow, and makes it independent of any particular plotting backend.
Visualizing neural spike trains#
To illustrate how the options system works, we will use a dataset containing “spike” (neural firing) events extracted from the recorded electrical activity of a neuron. We will be visualizing the first trial of this publicly accessible neural recording. First, we import pandas and holoviews and load our data:
import pandas as pd import holoviews as hv from holoviews import opts spike_train = pd.read_csv('../assets/spike_train.csv.gz') spike_train.head(n=3)
This dataset contains the spike times (in milliseconds) for each detected spike event in this five-second recording, along with a spiking frequency in Hertz (spikes per second), averaged over a rolling 200 millisecond window. We will now declare
Spike elements using this data and combine them into a
curve = hv.Curve( spike_train, 'milliseconds', 'Hertz', label='Firing Rate') spikes = hv.Spikes(spike_train, 'milliseconds', , label='Spike Train') layout = curve + spikes layout
:Layout .Curve.Firing_Rate :Curve [milliseconds] (Hertz) .Spikes.Spike_Train :Spikes [milliseconds]
Notice that the representation for this object is purely textual; so far we have not yet loaded any plotting system for HoloViews, and so all you can see is a description of the data stored in the elements.
To be able to see a visual representation and adjust its appearance, we’ll need to load a plotting system, and here let’s load two so they can be compared: