Pydlc
Simplified Python implementation of the Density Line Chart by Moritz & Fisher.
Install / Use
/learn @clberube/PydlcREADME
PyDLC - Density Line Charts with Python
Python implementation of the Density Line Chart (Moritz & Fisher, 2018) to visualize time series collections.
<p align="center"> <img src="./figures/example.png" width="75%"> </p>Installation
Python Package Index
$ pip install pydlc
Requirements
Usage
Example
The following example shows how to import and use the dense_lines plotting function.
import numpy as np
import matplotlib.pyplot as plt
from pydlc import dense_lines
# Generate random synthetic time series
x = np.linspace(0, 90, 25)
ys = []
for _ in range(10000):
ys.append(np.random.randn(1)*np.exp(-x/100))
# Plot here
fig, axs = plt.subplots(1, 2, figsize=(8, 3), sharey=True, sharex=True)
axs[0].plot(x, np.array(ys).T, lw=1) # this is slow and cluttered
axs[0].set_title('Line Chart')
im = dense_lines(ys, x=x, ax=axs[1], cmap='magma') # this is fast and clean
axs[1].set_title('Density Lines Chart')
fig.colorbar(im)
fig.tight_layout()
plt.show()
Arguments
- ys (
listof1darray): The lines to plot. Can also be passed as a2darray. - x (
1darray, optional): The x values corresponding to the data passed withys. If not provided,range(0, len(ys))is used. - ax (
matplotlib axes, optional): The axes to plot on. If not provided a new figure will be created. - ny (
int, optional): The vertical grid size. Higher values yield a smoother density estimation. Default: 100. - y_pad (
float, optional): The padding fraction to set the grid limits past the data values. Must be greater than 0. Default: 0.01. - normalize (
bool, optional): Normalize the plot so the density is between 0 and 1. Default: True. - **kwargs: Arbitrary keyword arguments to pass to
plt.imshow().
Limitations
- All series to be included in the density estimation and passed in the
ysargument must have the same length. - The vertical grid size can be adjusted with the
nyparameter. Higher values ofnyyield a smoother density visualization. However, the horizontal grid size is currently limited to the same size as the input sequences and there is no parameter to adjust it (yet).
Algorithm
This graphical abstract explains the algorithm (source).
<p align="center"> <img src="./figures/dense-lines.png" width="75%"> </p>Related Skills
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
104.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
