How to return figure name for curdoc?

As in the title.

def plot():
    p = figure(name='aaa')
    p.circle([1,2,3], [3,2,3])
    return p

curdoc().add_root(p)

There’s no robust way to do that since you can potentially call add_root multiple times or call it not on the figure directly but on some layout primitive.

Just store the name in a variable and use that variable inside the plot function, or pass it as a parameter.

Works. Thank you.