Skip to content
Discussion options

You must be logged in to vote

I think the main reason is that it is not implemented this way. In contrast to using a with-expression, update() doesn't translate the figure into HTML, so there is no new content to be sent to the client. The intention is to use ui.pyplot with Matplotlibs "pyplot" API (see https://matplotlib.org/stable/users/explain/figure/api_interfaces.html).

For the object-oriented API, I'd recommend using ui.matplotlib:

plot = ui.matplotlib()
with plot.figure as fig:
    x = np.linspace(0.0, 5.0)
    y = np.cos(2 * np.pi * x) * np.exp(-x)
    ax = fig.gca()
    ax.plot(x, y, '-')

def add_line():
    ax.axhline(0, color='red', linestyle='--')
    plot.update()

ui.button('Add line at y=0', on_click=a…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@falkoschindler
Comment options

Answer selected by dmenne
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants