#!/usr/bin/env python # coding: utf-8 # Use this notebook to obtain "expected" values for # ``` # test_geom_imshow_alpha.py # ``` # test suite. # In[1]: import numpy as np from lets_plot import * LetsPlot.setup_html() # In[2]: LetsPlot.set_theme(flavor_solarized_light()) # ### Greyscale image # In[3]: arr = np.array([ [50, 150, 200], [200, 100, 50] ]) # In[4]: ggplot() + geom_imshow(arr, alpha=.5) # In[5]: # 'norm' = False ggplot() + geom_imshow(arr, norm=False, alpha=.5) # In[6]: # With NaN-s arr_nan = np.array([ [50., np.nan, 200.], [np.nan, 100., 50.] ]) ggplot() + geom_imshow(arr_nan, alpha=0.5) # ### Alpha + cmap # In[7]: ggplot() + geom_imshow(arr, cmap="magma", alpha=0.5) # In[8]: # With NaN-s arr_nan = np.array([ [50., np.nan, 200.], [np.nan, 100., 50.] ]) ggplot() + geom_imshow(arr_nan, cmap="magma", alpha=0.5) # ### Color image # In[9]: # RGB image A2x3x3 = np.array([ [[255, 0, 0], [0, 255, 0], [0, 0, 255]], [[0, 255, 0], [0, 0, 255], [255, 0, 0]] ]) ggplot() + geom_imshow(A2x3x3) # In[10]: ggplot() + geom_imshow(A2x3x3, alpha=0.5) # In[11]: # RGBA image (with alpha channel) A2x3x4 = np.array([ [[1, 0, 0, 1], [0, 1, 0, 1], [0, 0, 1, 1]], [[0, 1, 0, 0.3], [0, 0, 1, 0.3], [1, 0, 0, 0.3]] ]) # In[12]: ggplot() + geom_imshow(A2x3x4) # In[13]: ggplot() + geom_imshow(A2x3x4, alpha=0.5) # In[14]: _.as_dict() # In[ ]: