-
-
Notifications
You must be signed in to change notification settings - Fork 640
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 potential matplotlib warning when using ui.line_plot.push #4192
Fix potential matplotlib warning when using ui.line_plot.push #4192
Conversation
Not updating the limits if the xs and ys have not difference in value. Added new parameters to disable updating a specific axis' limits.
Thanks a lot for this pull request, @drkspace! Checking for I just wonder if the two additional parameters line_plot.push([x], [[y]])
with line_plot:
plt.ylim([0, 1]) Sure, this is not very intuitive, so we might want to provide a parameter like def push(self, ..., y_limits: Union[None, Literal['auto'], Tuple[float, float]] = 'auto') -> None: (same for What do you think? Does that make sense, or am I missing something? |
line_plot.push([x], [[y]])
with line_plot:
plt.ylim([0, 1]) I don't think this is a good solution since it would require knowing the needed limits everywhere push is called. I can certainly imagine a use case where someone has many different places they are calling
That makes sense to me. The reason I added the ability to just turn of the auto update is because, in my code, I am setting the limits in 1 part of a class and updating the plot in another. Your suggestion should also allow that. I've updated the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I just shortened the docstring a little and decided to remove the extra demo because it was too similar to the first one. We can simply use the y_limits
parameter there to make the point. I think the docstring is clear enough about its usage.
Description
When trying to use
ui.line_plot.push
with x or y values that are all equal, you get the following matplotlib warning:This PR changes 2 things:
update_y_lims
andupdate_x_lims
parameters topush
that will disable the limits updating for that push. This will also allow for custom limits to be set (and not reset every call to push).Example
This example will have a warning on the current version of nicegui.