-
Notifications
You must be signed in to change notification settings - Fork 1
Spaces
A single plot can represent at most a few dimensions before it becomes visually cluttered. Since real world datasets often have higher dimensionality, however, we face a tradeoff between representing the full dimensionality of our data, and keeping the visual representation intelligible and therefore effective. In practice we are limited to two or at most three spatial axes, in addition to attributes such as the color, angle and size of the visual elements. To effectively explore higher dimensional spaces we can therefore have to find other solutions.
One way of dealing with this problem is to lay out multiple plots spatially, some plotting packages [Was14], [Wkh09] have shown how this can be done easily with various grid based layouts. Another solution, made possible by the interactivity of web-based technologies, is to introduce interactivity, allowing the user to reveal further dimensionality by interacting with the plots.
In HoloViews we solve this problem through a number of declarative and
composable data structures, which can embed visual elements in any
arbitrarily dimensioned space. In essence these data structures are
simply multi-dimensional dictionaries, allowing the user to declare
the dimensionality of the space via the key dimensions and the actual
keys as tuples matching the number of dimensions in length. In
addition to regular Python dictionary indexing these data structures
also support slicing semantics to select precisely the subregion of
the multi-dimensional space that the user wants to look at. Each of
these so called NdMapping
objects has a specific visual
representation but are otherwise interchangeable. The full list of
currently supported NdMapping
spaces includes:
- HoloMaps - The core data structure in HoloViews allowing Elements to be embedded in an n-dimensional space, which can be rendered as an animation (i.e. video) or as interactive widget.
- GridSpaces - A one or two dimensional data structure laying plots out in a grid, where each grid axis maps onto a key dimension.
- NdLayouts/NdOverlays - Dimensioned equivalents to the Layout and Overlay data structures introduced in the collections section.
To get a real sense of how composing data and generating complex
figures works within this framework we will explore some artificial
data in Figure 2. Here we will simply vary the frequency and amplitude
of a sine and cosine wave and discover how we can quickly and embed
this data in a dimensioned space. The first thing we have to do is to
declare the dimensions of the space we want to explore on a
HoloMap. At this point we could pass the data directly to the
constructor, but we will populate the space step-by-step instead,
iterating over the frequencies, amplitudes and trigonometric
functions, generating Curve Element one-by-one and setting them on the
HoloMap. Once we have populated the space we could go ahead and
display it. Visualizing a bunch of individual curves in isolation is
not very useful however, instead we want to see how the curves vary
across this space in a condensed plot. A GridSpace
provides such a
representation and by using one of the space conversion methods we can
trivially transform our three-dimensional HoloMap into a
two-dimensional GridSpace of one-dimensional HoloMaps. Finally we
simply let the HoloViews display system handle the plotting and
rendering.
Example of a HoloViews Spaces object being visualized in two different ways. A A GridSpace of NdOverlays providing a condensed representation of the simple HoloMap of Curve Elements in B.
If we decide that this isn't a very good representation of our data,
it is trivial to rearrange the dimensions in a different way without
any need to worry about writing new plotting code. Even very
high-dimensional spaces can be trivially condensed into a single plot,
animation or widget in this way without having to worry about the
plotting details. Additionally just like for simple Element
types,
spaces can be tabularized into a HoloViews Table
or pandas
dataframes and then be built back up into a different visual
representation in just a few lines of code.
[Was14] | Michael Waskom et al.. seaborn: v0.5.0, Zenodo. 10.5281/zenodo.12710, November 2014. |
[Wkh09] | Hadley Wickham, ggplot2: elegant graphics for data analysis, Springer New York, 2009. |