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

Add support for altair plots #2741

Merged
merged 14 commits into from
Dec 2, 2022
Merged

Add support for altair plots #2741

merged 14 commits into from
Dec 2, 2022

Conversation

freddyaboulton
Copy link
Collaborator

@freddyaboulton freddyaboulton commented Nov 29, 2022

Description

Run python demo/altair_plot/run.py

altair_demo

Getting the spacing to work out may be tricky. I tried setting the width and height to container (https://vega.github.io/vega-lite/docs/size.html#specifying-responsive-width-and-height) but that doesn't work (plot doesn't show up). To complicate matters, users can specify their own plot width and height on the python side so we should be careful to respect those choices.

For now I'm centering the plot to make it look nicer despite the white space.

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.

@github-actions
Copy link
Contributor

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

"@gradio/video": "workspace:^0.0.1",
"@gradio/uploadbutton": "workspace:^0.0.1"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this cause I got missing peer dependencies errors in pnpm. Not sure if it's actually needed

@freddyaboulton freddyaboulton marked this pull request as ready for review November 29, 2022 22:22
@abidlabs
Copy link
Member

This is really great @freddyaboulton! LGTM

Suggestions:

  • add Altair plots to the outbreak_forecast demo since that's our go-to demo for plots
  • add altair_plot as a demo in the docstring for the Plot component

Some suggestions for future:

  • When we implement our native plots, it would be great if we could make the plots have a transparent background instead of a white background so that they work well in dark mode too. Or we pass down the appropriate background color as part of the theme
  • It would be great if the Plot component could support .style(container=False) like the other components so that we could only display the plot and not the container if needed

@freddyaboulton
Copy link
Collaborator Author

@abidlabs Turns out transparent background will be straightforward. You can even specify that from the python side. I think the tricky thing will be applying the theme colors. Will definitely have to chat with @pngwn about that!

image

Thank you for the review!

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2022

The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes:

pip install nbformat && cd demo && python generate_notebooks.py

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2022

The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes:

pip install nbformat && cd demo && python generate_notebooks.py

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2022

The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes:

pip install nbformat && cd demo && python generate_notebooks.py

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2022

The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes:

pip install nbformat && cd demo && python generate_notebooks.py

Co-authored-by: aliabid94 <aabid94@gmail.com>
Copy link
Member

@pngwn pngwn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frontend looks good to me!

@freddyaboulton
Copy link
Collaborator Author

Thank you @pngwn !! 🐧

@freddyaboulton freddyaboulton merged commit bed288a into main Dec 2, 2022
@freddyaboulton freddyaboulton deleted the altair-plots branch December 2, 2022 17:53
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.

4 participants