# See: https://ipywidgets.readthedocs.io/en/latest/examples/Using%20Interact.html
# for more details about the widgets
%matplotlib inline
from ipywidgets import interactive, fixed
import matplotlib.pyplot as plt
import numpy as np
# Now using matplotlib for visualization
def create_rgb_pixel(r, g, b, size=255):
rgb_img = np.ones((size, size, 3), dtype=np.uint8) * np.array([[[r, g, b]]], dtype=np.uint8)
plt_img = plt.imshow(rgb_img, vmin=0, vmax=255)
# This removes the ticks and keeps the black border
plt.xticks([], [])
plt.yticks([], [])
return plt_img
interactive_plot = interactive(
create_rgb_pixel, r=(0, 255), g=(0, 255), b=(0, 255), size=fixed(255)
)
output = interactive_plot.children[-1]
output.layout.height = '250px'
interactive_plot