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

Real-time updating of plot data #30

Closed
tbreloff opened this issue Sep 24, 2015 · 22 comments
Closed

Real-time updating of plot data #30

tbreloff opened this issue Sep 24, 2015 · 22 comments

Comments

@tbreloff
Copy link
Member

I have lots of applications which require adding to or replacing the underlying x/y data in my plots. I want a simple interface which likely overloads base methods like push!, etc.

Here's a sample prototype (backend is Immerse):

tmp

@joshday
Copy link
Contributor

joshday commented Sep 24, 2015

👍 I started messing around with plotting methods for OnlineStats, so this would be great.

@lobingera
Copy link

Better call it 'near-real-time' updating, or 'Update Data'. People would expect real-time plotting and for e.g. a PDF output that's hard to do...

@tbreloff
Copy link
Member Author

@joshday Cool... are you working on the "josh" branch? I have some ideas there... maybe we should start an issue to discuss at OnlineStats?

@lobingera I hear ya... certainly the degree of "real-time-ness" depends on the backend. Likely UnicodePlots and Gadfly aren't good for this, but any of the others could be?

@lobingera
Copy link

But it like this: real-time-update sounds like you connect some data with some graph and if the data is updated, the graph follows. Actually earlier (some months ago) i asked if the REPL can support this -> filter, what has been changed (LHS of evaluation,assignment) and feed that information somewhere. Back then the REPL wasn't able, but maybe now. In any case you need some infrastructure to get that change down. How about auto-scaling in cases like this?

@tbreloff
Copy link
Member Author

real-time-update sounds like you connect some data with some graph and if the data is updated, the graph follows

This is exactly what I want to do, and the prototype can already work this way. You can just call gui() to update the display between each push!.

This currently works as expected (on master)... one extra point is added to the graph every half-second:

using Plots; immerse!()
plt = plot([0,0.1], Any[rand(2),sin])
for x in 0.2:0.1:π
    push!(plt, 1, x, rand())
    push!(plt, 2, x, sin(x))
    gui(); sleep(0.5)
end

@lobingera
Copy link

as a side question: why immerse!() ? I thought, ! methods are supposed to change the argument, and there's little argument

@tbreloff
Copy link
Member Author

@lobingera My interpretation of ! methods is that they are appropriate whenever you are changing state (whether or not that state belongs to the arguments). For this particular case, I agree that the ! probably isn't necessary, and I could add immerse() to do the same thing.

@tbreloff
Copy link
Member Author

Also technically speaking the plot!(rand(10)) calls fall into this category as well. You're changing the state of a Plot object, but it's not an argument to the method, it just happens to change the state of the return value from currentPlot().

@lobingera
Copy link

Statefull vs. stateless plot commands is a tricky thing. Statefull makes great sense in REPL, but not necessarily in scripted plotting. And maybe this discussion should be in #1

@tbreloff
Copy link
Member Author

I don't think I understand your point. Why is REPL any different than scripting here?

@tbreloff
Copy link
Member Author

In regards to the real-time-ness discussion, I ran a quick test... 17 millis per update may not be "real-time" but it's certainly close enough for most applications (and certainly better than re-writing a PDF every time). However, in most cases you wouldn't update the display after every data point unless the points were updating very slowly.

tmp

@lobingera
Copy link

@tbreloff
In the REPL you work with a single scope, so the state will be atomic. When you run a script in a single instance you will use a single state, but what if you try to parallelize?

@tbreloff
Copy link
Member Author

You can always call plot!(plt, args...; kw...) and control which object's state is changed...

On Sep 24, 2015, at 5:04 PM, Andreas Lobinger notifications@github.com wrote:

@tbreloff
In the REPL you work with a single scope, so the state will be atomic. When you run a script in a single instance you will use a single state, but what if you try to parallelize?


Reply to this email directly or view it on GitHub.

@tbreloff
Copy link
Member Author

I have pretty good support for updating plots now, so closing this.

@zsoerenm
Copy link

Is there a way to push errorbars or ribbons?
Something like this?

push!(plt, 3, 1, err = 2)
push!(plt, 3, 1, ribbon = 2)

If not is there a workaround?
At the moment I get the following error:

ERROR: function push! does not accept keyword arguments

@mkborregaard
Copy link
Member

plot!?

@zsoerenm
Copy link

zsoerenm commented Aug 22, 2017

Well, I think plot! does only add a new line to the current plot, doesn't it?
Whereas, I want to extend a current errorbar / ribbon at the end with a new value.

@mkborregaard
Copy link
Member

If you give an MWE I wouldn't mind commenting on what you're doing. But push! isn't defined for Plot objects.

@zsoerenm
Copy link

zsoerenm commented Aug 22, 2017

Here you go:

using Plots
plt = plot(1:10, zeros(10), err = randn(10))
push!(plt, 1, 11, 0.1)

figure_1

This extends the line without the errorbar by a new value.
Is there a way to do the same for the errorbars?

@mkborregaard
Copy link
Member

Ha, I didn't realize you could do that :-) I just looked at the code, and no, it doesn't seem like you can do that, sry.

@zsoerenm
Copy link

I think I found a workaround using plot!

using Plots

plt = plot(1:10, zeros(10), err = randn(10))
plot!(plt, 11:11, 0.1:0.1, err = 0.5, legend=false)
push!(plt, 1, 11, 0.1)

figure_1
Thanks for taking your time

@adhal007
Copy link

I have a plot for each of a 100 samples run for 1000 iterations, so it creates an array of 100 plots. How is it possible to merge these into one plot ?

Thank you for your inputs

t-bltg pushed a commit that referenced this issue Oct 6, 2022
t-bltg pushed a commit that referenced this issue Oct 6, 2022
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

No branches or pull requests

6 participants