Using dropdown to select legend.location

I am attempting to use a dropdown to control legend location with errors on the js_link portion of the following code.

menu = [('Top Right', 'top_right'),('Top Left', 'top_left'), ('Top Center','top_center'),('Bottom  
    Right','bottom_right'),('Bottom Center','bottom_center'),('Bottom Left','bottom_left'),('Center 
    Left','center_left'),('Center Right','center_right'),('Center','center')]
Drop1 = Dropdown(label = 'Legend Position', menu = menu)
Drop1.js_link('value', tps.legend.location,"type")

I have tried variation to the js_link code such as:

    Drop1.js_link('type', tps.legend.location,"value")
    Drop1.js_link('value', tps.legend, 'location')
    Drop1.js_link(tps.legend, 'location',  attr_selector=0)
    Drop1.js_link(tps.legend, 'location')
    Drop1.js_link(tps.legend, 'value')

Thanks for any advice!

To be honest I can’t recall anyone ever asking about moving a legend location after plot initialization before, and I am not aware that there are any tests that exercise this usage pattern. I think it’s reasonably likely that moving a legend post-initialization is just not presently supported. cc @mateusz in case he has any knowledge to the contrary. Otherwise I think it would be appropriate to open a GitHub Issue to request support for this in a future release.

Thank You for the reply and I will take your advice.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.