Skip to content
jlstevens edited this page Jun 11, 2015 · 9 revisions

A single plot can represent at most a few dimensions before it becomes visually cluttered. Since real world datasets often have higher dimensionality, 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 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 is to introduce interactivity, allowing the user to reveal further dimensionality by interacting with the plots.

In HoloViews, we solve this problem with composable data structures that embed Element objects in any arbitrarily dimensioned space. Fundamentally, this set of data structures (subclasses of NdMapping) are multi-dimensional dictionaries that allow the user to declare the dimensionality of the space via a list of key dimensions (kdims). The multi-dimensional location of the items held by the dictionary are defined by tuples where the values in the tuple matches the declared key dimension by position. In addition to regular Python dictionary indexing semantics these data structures also support slicing semantics to select precisely the subregion of the multi-dimensional space that the user wants to explore.

The full list of currently supported NdMapping classes includes:

  • HoloMaps: The most flexible high-dimensional data structure in HoloViews that allows Element instances to be embedded in an arbitrarily high-dimensional space, that is rendered either as an animation (i.e. video) or as an interactive plot that allows exploration via a set of widgets.
  • GridSpaces: A data structure for generating spatial layouts with either a single row (1D) or a two-dimensional grid. Each overall grid axis corresponds to a key dimensions.
  • NdLayouts/NdOverlays: Unlike Layout or Overlay objects, these spaces only support homogenous sets of elements but allow you to define the various dimensions over which these items vary.

All of the above classes are simply different ways to convey a high-dimensional dataset. Just as with Elements it is possible to cast between these different spaces via the constructor (although GridSpace``is restricted to a maximum of two dimensions). In addition, they can all be tabularized into a HoloViews ``Table element or a pandas DataFrame, a feature that is also supported by the Element primitives.

To get a sense of how composing data and generating complex figures works within this framework we explore some artificial data in Figure :ref:`spaces`. Here we will vary the frequency and amplitude of sine and cosine waves demonstrating how we can quickly embed this data into a high-dimensional space. The first thing we have to do is to declare the dimensions of the space we want to explore as the key dimensions (kdims) of the HoloMap. Next we populate the space iterating over the frequencies, amplitudes and trigonometric functions, generating Curve element individually and assigning to the HoloMap at the correct position in the declared multi-dimensional space.

We can immediately go ahead and display this HoloMap either as an animation or using the default widgets. Visualizing individual curves in isolation is not very useful however, instead we want to see how the curves vary across Frequency and Amplitude in a single plot. A GridSpace provides such a representation and by using of the space conversion method .grid we can easily transform our three-dimensional HoloMap into a two-dimensional GridSpace (which then allows the trigonometric function to be varied via the drop-down menu). Finally, after composing a Layout together with the original HoloMap, we let the display system handle the plotting and rendering.

spaces_example.png

Example of a HoloViews Spaces object being visualized in two different ways. A GridSpace providing a condensed representation of Curve Elements across 'Frequency' and 'Amplitude'. 🏷️`spaces`

If we decide that a different representation of the data would be more appropriate, it is trivial to rearrange the dimensions without needing to write new plotting code. Even very high-dimensional spaces can be condensed into an individual plot or expressed as an interactive plot or animation.

[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.
Clone this wiki locally