This library is since 18-01-2023 fully implemented in D3Blocks. This repo will be froozen at v0.2.3 and not updated anymore. Please use heatmap in D3Blocks for updates and further support.
d3heatmap
is a Python package to create interactive heatmaps based on d3js.
- The aim of d3heatmap is to create interactive heatmaps that can be used stand-alone and being visual attractive.
- This library does not require any additional installation of javascript, or downloads or setting paths to your systems environments. You just need python and pip install this library. There are two main functions to create a heatmap and there are some differences between the two. Read below for more details. Have fun!
pip install d3blocks
# Import
from d3blocks import D3Blocks
# Initialize
d3 = D3Blocks()
# Load example data
df = d3.import_example('stormofswords')
df = d3.vec2adjmat(df['source'], df['target'], weight=df['weight'], symmetric=True)
# Plot
d3.heatmap(df)
d3heatmap.matrix
- Allows none symetric adjacency matrices.
- Colormap can be changed.
- No clustering.
- round-ish elements.
d3heatmap.heatmap
- Allows Clustering.
- Colormap is fixed.
- Advanced cluster coloring. Clusters are colored and within each cluster the color is incremental based on the value.
- Adjacency matrix must be symetric.
Star the D3Blocks repo if you like it! ⭐️
pip install d3heatmap
- Alternatively, install d3heatmap from the GitHub source:
git clone https://github.com/erdogant/d3heatmap.git
cd d3heatmap
pip install -U .
from d3heatmap import d3heatmap as d3
df = d3.import_example()
# Create heatmap
paths = results = d3.heatmap(df)
Klik on the figure for the interactive example.
df = d3.import_example(size=(6,20))
# Create heatmap
paths = d3.matrix(df)
# The dataframe contains more columns then rows. Adjust the size and color differently.
df = d3.import_example(size=(6,20))
# Create heatmap
paths = d3.matrix(df, fontsize=10, title='Hooray!', description='d3 matrix is created using https://github.com/erdogant/d3heatmap.', path='c:/temp/example/d3_matrix.html', width=600, height=300, cmap='interpolateGreens', vmin=1)
# The dataframe contains more columns then rows. Adjust the size and color differently.
df = d3.import_example(size=(6,20))
# Create heatmap
paths = d3.matrix(df, fontsize=10, title='Hooray!', description='d3 matrix is created using https://github.com/erdogant/d3heatmap.', path='c:/temp/example/d3_matrix.html', width=600, height=300, cmap='interpolateGreens', vmin=1)
There are quit some differences between the heatmap
vs matrix
functionality.
df = d3.import_example()
results = d3.heatmap(df, title='d3heatmap with the heatmap function.', path='heatmap.html')
results = d3.matrix(df, title='d3heatmap with the matrix function.', cmap='interpolatePRGn', path='matrix.html', width=700, height=700)
Please cite d3heatmap in your publications if this is useful for your research. See right column for citation information.