Skip to main content

imagesc is an Python package to create heatmaps in a easy way.

Project description

imagesc

Python PyPI Version License Github Forks GitHub Open Issues Project Status Downloads Downloads

  • imagesc is an Python package to create heatmaps. Various methods to create a heatmap are implemented, each with specific properties that can help to easily create your heatmap. The fast and clean method is optimized for speed, the cluster method provides clustering, the seaborn method contains many configuration settings, and finally, the plot as good as possible the imagesc from matlab.

Star this repo if you like it! ⭐️

Functions in imagesc

# X is your numpy array
fig  = imagesc.seaborn(X)
fig  = imagesc.cluster(X)
fig  = imagesc.fast(X)
fig  = imagesc.clean(X)
fig  = imagesc.plot(X)
status = imagesc.savefig(fig)
path = imagesc.d3(df)

Contents

Installation

  • Install imagesc from PyPI (recommended). imagesc is compatible with Python 3.6+ and runs on Linux, MacOS X and Windows.
  • It is distributed under the MIT license.

Requirements

# Note that: seaborn is only required when using **seaborn** or **cluster** functions.
pip install -r requirements.txt

Installation from Pypi

pip install imagesc

Import imagesc package

import imagesc as imagesc

d3

df = pd.DataFrame(np.random.randint(0, 100, size=(50, 50)))
imagesc.d3(df, vmax=1)

seaborn

df = pd.DataFrame(np.random.randint(0,100,size=(10,20)))
A = imagesc.seaborn(df.values, df.index.values, df.columns.values)
B = imagesc.seaborn(df.values, df.index.values, df.columns.values, annot=True, annot_kws={"size": 12})
C = imagesc.seaborn(df.values, df.index.values, df.columns.values, annot=True, annot_kws={"size": 12}, cmap='rainbow')
D = imagesc.seaborn(df.values, df.index.values, df.columns.values, annot=True, annot_kws={"size": 12}, cmap='rainbow', linecolor='#ffffff')

A B C D

cluster

  • Underlying implemented is based on clustermap
  • When you desire to cluster your heatmap
  • Default distance setting: metric="euclidean", linkage="ward" (can be changed)
  • Slow for large data sets
  • Grid is aligned to the cells
  • Possibilities to tweak
  • Possible arguments: https://seaborn.pydata.org/generated/seaborn.clustermap.html
df = pd.DataFrame(np.random.randint(0,100,size=(10,20)))
fig_C1 = imagesc.cluster(df.values, df.index.values, df.columns.values)
fig_C2 = imagesc.cluster(df.values, df.index.values, df.columns.values, cmap='rainbow')
fig_C3 = imagesc.cluster(df.values, df.index.values, df.columns.values, cmap='rainbow', linecolor='#ffffff')
fig_C4 = imagesc.cluster(df.values, df.index.values, df.columns.values, cmap='rainbow', linecolor='#ffffff', linewidth=0)
imagesc.savefig(fig_C1, './docs/figs/cluster4.png')

C1 C2 C3 C4

fast

df = pd.DataFrame(np.random.randint(0,100,size=(10,20)))
fig_F1 = imagesc.fast(df.values, df.index.values, df.columns.values)
fig_F2 = imagesc.fast(df.values, df.index.values, df.columns.values, grid=False)
fig_F3 = imagesc.fast(df.values, df.index.values, df.columns.values, grid=False, cbar=False)
fig_F4 = imagesc.fast(df.values, df.index.values, df.columns.values, grid=True, cbar=False)
fig_F5 = imagesc.fast(df.values, df.index.values, df.columns.values, cmap='rainbow')
fig_F6 = imagesc.fast(df.values, df.index.values, df.columns.values, cmap='rainbow', linewidth=0.5, grid=True)
imagesc.savefig(fig_C1, './docs/figs/fast1.png')

F1 F2 F3 F4 F5 F6

clean

df = pd.DataFrame(np.random.randint(0,100,size=(10,20)))
fig_FC1 = imagesc.clean(df.values)
fig_FC2 = imagesc.clean(df.values, cmap='rainbow')
imagesc.savefig(fig_C1, './docs/figs/clean1.png')

F1 F2

plot

df = pd.DataFrame(np.random.randint(0,100,size=(10,20)))
fig_M1 = imagesc.plot(df.values)
fig_M2 = imagesc.plot(df.values, cbar=False)
fig_M3 = imagesc.plot(df.values, cbar=False, axis=False)
fig_M4 = imagesc.plot(df.values, cbar=False, axis=True, linewidth=0.2)
fig_M5 = imagesc.plot(df.values, df.index.values, df.columns.values)
fig_M6 = imagesc.plot(df.values, df.index.values, df.columns.values, cbar=False, linewidth=0.2)
fig_M7 = imagesc.plot(df.values, df.index.values, df.columns.values, grid=True, cbar=False, linewidth=0.2)
fig_M8 = imagesc.plot(df.values, df.index.values, df.columns.values, grid=False, cbar=False, linewidth=0.2)
fig_M9 = imagesc.plot(df.values, df.index.values, df.columns.values, grid=True, cbar=False, linewidth=0.8, linecolor='#ffffff')
fig_M10 = imagesc.plot(df.values, df.index.values, df.columns.values, grid=True, cbar=False, linewidth=0.8, linecolor='#ffffff', cmap='rainbow')
imagesc.savefig(fig, './docs/figs/plot10.png')imagesc.savefig(fig_C1, './docs/figs/fast1.png')

M1 M2 M3 M4 M5 M6 M7 M8 M9 M10

Speed:

import matplotlib.image as mpimg
img=mpimg.imread('./docs/figs/lenna.png')

fig = imagesc.clean(img)
# runtime 1.49

fig = imagesc.fast(img, cbar=False, axis=False)
# runtime: 2.931 seconds

fig = imagesc.plot(img, linewidth=0, cbar=False)
# runtime: 11.042

**fast** **clean** **plot**

Citation

Please cite imagesc in your publications if this is useful for your research. Here is an example BibTeX entry:

@misc{erdogant2019imagesc,
  title={imagesc},
  author={Erdogan Taskesen},
  year={2019},
  howpublished={\url{https://github.com/erdogant/imagesc}},
}

References

Maintainer

  • Erdogan Taskesen, github: erdogant
  • Contributions are welcome.
  • If you wish to buy me a Coffee for this work, it is very appreciated :)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imagesc-0.3.0.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

imagesc-0.3.0-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file imagesc-0.3.0.tar.gz.

File metadata

  • Download URL: imagesc-0.3.0.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for imagesc-0.3.0.tar.gz
Algorithm Hash digest
SHA256 1dfd0dad5b2c4094e8e553fe509b886a17cdd4606069f12988a6825eeba4711c
MD5 15198242b4feeaed1956d30d37b643e8
BLAKE2b-256 8c175f730265ac5d504f279b1825dbc0f9963bdf74017504264e1ff984125ec3

See more details on using hashes here.

File details

Details for the file imagesc-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: imagesc-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for imagesc-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd9585a5ea6a1ae7ca03233085cee8a87dda7e9fb90f764d92cbabf4e135e118
MD5 3adc75ef3946740a6cf602d024608ea4
BLAKE2b-256 3428262e9952004d76dec8c432d2d7ce52013fb296e084e0c0d33e0aae5c1109

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page