Jupyter Graph Display with Interactive button.

77 views
Skip to first unread message

Kayvon Crenshaw

unread,
Oct 4, 2022, 11:03:56 AM10/4/22
to jup...@googlegroups.com
Hello, can I get some help with using python ipywidgets button interactions within Jupyter Notebook? Here is my code:
if (direction == 'Downward'):
    # Convert to Lab color space and extract the "a" channel
    a = rgb2lab(img)[:,:,1].astype(np.float32)
    # Calculate vegetation index
    VI = 1-(a-a.min())/(a.max()-a.min())    
    fig = plt.figure(figsize=(12,6))
    ax1 = fig.add_subplot(1,2,1)
    ax1.set_title('The "a" channel')
    #im = ax1.imshow(a)
    #ax2 = fig.add_subplot(1,2,2)
    #ax2.set_title('Vegetation index')
    #im = ax2.imshow(VI) 
    #widgets.interact(on_btn_click, direction=)
    btn = widgets.Button(description = 'The "a" channel',
                disabled = False, 
                button_style='',
                options= ax1.imshow(a)
                )
For my output, my button displays, yet, when it is clicked/activated, then nothing pops up. What could be the exact reason for this? Also, the graph displays automatically without me clicking the button. I want it to only display once I click the button.
image.png
Reply all
Reply to author
Forward
0 new messages