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

Feature request: Add editable data in plots #34

Closed
PabloRuizCuevas opened this issue Aug 17, 2024 · 2 comments
Closed

Feature request: Add editable data in plots #34

PabloRuizCuevas opened this issue Aug 17, 2024 · 2 comments
Assignees
Labels
feature request New feature or request question Further information is requested

Comments

@PabloRuizCuevas
Copy link
Contributor

PabloRuizCuevas commented Aug 17, 2024

The objective of this proposal is being able to redraw the plot without changing axis labels etc.

There are several ways of adding this feature, the one used in matplotlib is using an instance of a class, but as first draft I developed a simple generator that is able to do the same:

https://github.com/PabloRuizCuevas/uniplot/blob/master/uniplot/uniplot.py

    from uniplot import plot_gen
    plot_g = plot_gen(
        **{
            "lines": [True, True],
            "width": 180,
            "x_unit": "$",
            "y_unit": "$",
            "color": ["green", "red"],
        }
    )
    next(plot_g)
    args = {}
    plot_g.send(([1,2,3], [4,3,2], args)) # pass only data that changes.
    # the plot is plotted
    plot_g.send(([1,2,3], [2,3,2], args))
    # the plot is modified

With this structure we avoid creating a class for the plot, though it may be desirable to do so, I could also make a draft of that if you like it more.

olavolav added a commit that referenced this issue Dec 7, 2024
This should address #34 and relates to PR #35.
@olavolav olavolav added feature request New feature or request question Further information is requested labels Dec 7, 2024
@olavolav olavolav self-assigned this Dec 7, 2024
@olavolav
Copy link
Owner

olavolav commented Dec 7, 2024

@PabloRuizCuevas I've been thinking about this in the context of how to make the library more flexible for different use cases, also how it relates to #23.

What I did for v0.16.0 is to add a plot_gen function that should essentially do what you need. I did run into issues with the generator functionality itself, so it's just a simple wrapper but should work. You can check out examples/5-streaming.py to see if this is what you need.

@olavolav olavolav closed this as completed Dec 7, 2024
@PabloRuizCuevas
Copy link
Contributor Author

@olavolav Just tested the functionality, it works perfectly! many thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants