It takes as input an ipywidgets
Image widget
In [ ]:
import os
import ipywidgets as widgets
import bqplot.pyplot as plt
from bqplot import LinearScale
In [ ]:
image_path = os.path.abspath('../../data_files/trees.jpg')
with open(image_path, 'rb') as f:
raw_image = f.read()
ipyimage = widgets.Image(value=raw_image, format='jpg')
ipyimage
In [ ]:
plt.figure(padding_y=0)
axes_options = {'x': {'visible': False}, 'y': {'visible': False}}
plt.imshow(image_path, 'filename')
plt.show()
In [ ]:
fig = plt.figure(title='Trees', padding_x=0, padding_y=0)
image = plt.imshow(ipyimage, 'widget')
fig
In [ ]:
fig = plt.figure(padding_x=0, padding_y=0)
plt.scales(scales={'x': LinearScale(min=-1, max=2),
'y': LinearScale(min=-0.5, max=2)})
image = plt.imshow(ipyimage, format='widget')
plt.plot([0, 1, 1, 0, 0], [0, 0, 1, 1, 0], 'r')
fig
Its traits (attributes) will also respond dynamically to a change from the backend
In [ ]:
# Full screen
image.x = [-1, 2]
image.y = [-.5, 2]