Skip to content

RemiLehe/transparent_imshow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This is a simple wrapper around matplotlib's imshow function, which allows to produce images with pixel-dependent transparency. This can be particularly useful to overlay several images.

The solution implemented was inspired by this post.

Example

Below is a simple example that shows how to overlay two arrays of data, by using the function transp_imshow which is provided in this package.

import numpy as np
import matplotlib.pyplot as plt
from transparent_imshow import transp_imshow

# Create some data
x, y = np.meshgrid( np.linspace(-2, 2, 100), 
                   np.linspace(-2, 2, 100) )
data1 = y
data2 = np.exp( -x**2 -y**2 )

# Plot with transparency
plt.imshow( data1, cmap='Spectral' )
transp_imshow( data2, cmap='Greys' )

The code produces the following image:

image

For more information on the function transp_imshow, see its docstring.

Installation

In order to install this package, type:

pip install git+https://github.com/RemiLehe/transparent_imshow

About

Pixel-dependent transparency with matplotlib's imshow

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages