Skip to content

LinePlot#2807

Merged
freddyaboulton merged 15 commits into
mainfrom
line-plot
Dec 20, 2022
Merged

LinePlot#2807
freddyaboulton merged 15 commits into
mainfrom
line-plot

Conversation

@freddyaboulton
Copy link
Copy Markdown
Collaborator

@freddyaboulton freddyaboulton commented Dec 13, 2022

Description

Addition of gr.LinePlot with api similar to gr.ScatterPlot.

gr.LinePlot(value=data,
                    x="date", y="downloads",
                    tooltip=['date', 'downloads'],
                    title=f"Pypi downloads of {lib} over last {time}",
                    overlay_point=True, height=400, width=900)

line_plot_demo

To test, run the unit tests and run native_plots demo. You can check it out in the deployed space once spaces start to build again.

I also added the following to both LinePlot and ScatterPlot:

  • Ability to set x and y axis limits
  • Ability to move the position of the legend

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

@github-actions
Copy link
Copy Markdown
Contributor

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

@freddyaboulton freddyaboulton force-pushed the line-plot branch 2 times, most recently from ba4251f to 4ea648e Compare December 15, 2022 19:42
@github-actions
Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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

2 similar comments
@github-actions
Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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

@freddyaboulton freddyaboulton changed the title WIP: LinePlot LinePlot Dec 16, 2022
@freddyaboulton freddyaboulton marked this pull request as ready for review December 16, 2022 19:35
@freddyaboulton freddyaboulton requested review from abidlabs, aliabd, aliabid94, dawoodkhan82 and pngwn and removed request for pngwn December 16, 2022 19:35
Comment thread gradio/components.py
Comment thread CHANGELOG.md

## Full Changelog:
No changes to highlight.
* Added the ability to set `x_lim`, `y_lim` and legend positions for `gr.ScatterPlot` by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2807](https://github.com/gradio-app/gradio/pull/2807)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

Comment thread gradio/components.py Outdated
Copy link
Copy Markdown
Member

@abidlabs abidlabs Dec 18, 2022

Choose a reason for hiding this comment

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

Suggested change
x_lim: A tuple or list containing the limits for the x-axis.
x_lim: A tuple or list containing the limits for the x-axis, specified as [x_min, x_max].

Comment thread gradio/components.py Outdated
Comment on lines 4221 to 4225
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just to clarify, what does "If 'none', omit the legend" mean? if any of these None, the legend is omitted?

Comment thread gradio/components.py Outdated
Copy link
Copy Markdown
Member

@abidlabs abidlabs Dec 18, 2022

Choose a reason for hiding this comment

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

Suggested change
y_lim: A tuple of list containing the limits for the y-axis.
y_lim: A tuple of list containing the limits for the y-axis, specified as [y_min, y_max].

Comment thread gradio/components.py Outdated
Comment on lines 4459 to 4462
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same question as above about the Scatterplot

Comment thread gradio/components.py Outdated
Comment on lines 4463 to 4466
Copy link
Copy Markdown
Member

@abidlabs abidlabs Dec 18, 2022

Choose a reason for hiding this comment

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

Suggested change
x_lim: A tuple or list containing the limits for the x-axis.
y_lim: A tuple of list containing the limits for the y-axis.
x_lim: A tuple or list containing the limits for the x-axis, specified as [x_min, x_max].
y_lim: A tuple of list containing the limits for the y-axis, specified as [y_min, y_max].

@abidlabs
Copy link
Copy Markdown
Member

abidlabs commented Dec 18, 2022

I ran the native_plots demo and I'm getting this error:

altair.utils.schemapi.SchemaValidationError: Invalid specification

        altair.vegalite.v4.schema.channels.SizeValue, validating 'additionalProperties'

        Additional properties are not allowed ('selection' was unexpected)

I think it's because I'm using an older version of altair, let me check

Edit: yes, the error was present with altair==4.1.0, but not with altair==4.2.0. I don't know why I had the older version installed but given that 4.2.0 was released a year ago (interestingly no later releases: https://pypi.org/project/altair/#history), it should be fine to update altair>=4.2.0 in our requirements file

Copy link
Copy Markdown
Member

@abidlabs abidlabs left a comment

Choose a reason for hiding this comment

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

Tested and everything works great, as long as I have altair>=4.2.0. Fantastic PR @freddyaboulton!

@freddyaboulton
Copy link
Copy Markdown
Collaborator Author

Thank you for the review @abidlabs !

@freddyaboulton freddyaboulton merged commit 96297c0 into main Dec 20, 2022
@freddyaboulton freddyaboulton deleted the line-plot branch December 20, 2022 16:13
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.

2 participants