Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug multiple bokeh plots #3896

Merged
merged 3 commits into from
Apr 18, 2023
Merged

Conversation

freddyaboulton
Copy link
Collaborator

@freddyaboulton freddyaboulton commented Apr 17, 2023

Description

Closes: #3881

Issue was that the same div was edited across multiple plots. Using unique div ids fixes the problem.

To test, run repro in issue

import gradio as gr
from bokeh.plotting import figure

with gr.Blocks() as demo:
    x = list(range(11))
    y0 = x
    y1 = [10 - i for i in x]

    p1 = gr.Plot(label='Plot 1')
    b1 = gr.Button('B1')
    p2 = gr.Plot(label='Plot 2')
    b2 = gr.Button('B2')

    def plot1():
        fig = figure(width=250, height=250, title='Plot1')
        fig.circle(x, y0, size=10, color="navy", alpha=0.5)
        return fig

    def plot2():
        fig = figure(width=250, height=250, title='Plot2')
        fig.triangle(x, y1, size=10, color="firebrick", alpha=0.5)
        return fig

    b1.click(plot1, outputs=p1)
    b2.click(plot2, outputs=p2)

    demo.launch()

image

Checklist:

  • I have performed a self-review of my own code
  • I have added a short summary of my change to the CHANGELOG.md
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

A note about the CHANGELOG

Hello 👋 and thank you for contributing to Gradio!

All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.

Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections.
If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the
GitHub web UI since that lets you upload files directly via drag-and-drop.

@gradio-pr-bot
Copy link
Collaborator

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-3896-all-demos

@freddyaboulton freddyaboulton marked this pull request as ready for review April 17, 2023 19:22
@abidlabs
Copy link
Member

LGTM nice fix @freddyaboulton!

@freddyaboulton
Copy link
Collaborator Author

Thanks for the review @abidlabs !

@freddyaboulton freddyaboulton merged commit f81b823 into main Apr 18, 2023
@freddyaboulton freddyaboulton deleted the 3881-bokeh-multiple-plot-bug branch April 18, 2023 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple plots with Bokeh
3 participants