Implementing `plt.psd`, and the canonical meaning of an `Element`

My particular use case is that I’d like extend Holoviews to view the power spectral density or Fourier transform of my data. However, I’m not sure exactly where this code would go.

The core FFT routine would get wrapped in an Operation, but it could also be integrated into an Element, i.e. hv.Fourier or something like this. It could be similar to plt.psd. Some Elements, like hv.Bivariate and hv.HexTiles, automatically perform transformations on the data, rather than directly plotting the raw data. However, others, like hv.Histogram, does not calculate the histogram for you but rather plots an already-calculated histogram.

Personally, I find the hv.Histogram model a little inconvenient, but I’m not sure if I’m just using it wrong, and there’s a clean way to also calculate the histogram. Mostly, I just try to rely on hvplot for plotting histograms.

Any advice on the best way to implement something like this? Thank you!

We do too, we’ve long debated renaming Histogram to ContinuousBars (or hopefully something better) and then introducing a real Histogram element. For your use case I think an Operation is exactly the right approach, if you then want to introduce an element that automatically gets transformed the way hv.Bivariate or hv.HexTiles does that should be straightforward as well.

2 Likes