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

[BUG] Plot from .jl file does not appear. #483

Closed
KaioBenedetti opened this issue Feb 17, 2020 · 3 comments
Closed

[BUG] Plot from .jl file does not appear. #483

KaioBenedetti opened this issue Feb 17, 2020 · 3 comments
Labels

Comments

@KaioBenedetti
Copy link

I am trying to replicate an example from Dynamical Systems
https://juliadynamics.github.io/DynamicalSystems.jl/latest/chaos/orbitdiagram/#ChaosTools.poincaresos
and the plotting seems to be broken. Here is the code:

`using DynamicalSystems
using Plots

ds = Systems.shinriki([-2, 0, 0.2])

pvalues = range(19, stop = 22, length = 401)
i = 1
plane = (2, 0.0)
tf = 200.0
p_index = 1

output = produce_orbitdiagram(ds, plane, i, p_index, pvalues;
tfinal = tf, Ttr = 200.0)

pyplot()
for (j, p) in enumerate(pvalues)
plot(fill(p, length(output[j])), output[j], lw = 0,
marker = "o", ms = 0.2, color = "black")
end`

The program did get executed, but I have got no graph output.
I tried to rebuild the Plots package, with no success either. Only when I command directly from the REPL I got the graph.

@aviatesk
Copy link
Member

How did you run the program ?
If you use Julia Client: Run All command, it won't show outputs that don't appear in stdout.
Inline evals like Julia Client: Run Block will show outputs as in REPL.

@pfitzseb
Copy link
Member

Generally you need to actually display the plot, so try something like

using DynamicalSystems
using Plots

ds = Systems.shinriki([-2, 0, 0.2])

pvalues = range(19, stop = 22, length = 401)
i = 1
plane = (2, 0.0)
tf = 200.0
p_index = 1

output = produce_orbitdiagram(ds, plane, i, p_index, pvalues;
tfinal = tf, Ttr = 200.0)

pyplot()
for (j, p) in enumerate(pvalues)
  display(plot(fill(p, length(output[j])), output[j], lw = 0,marker = "o", ms = 0.2, color = "black"))
end

@KaioBenedetti
Copy link
Author

KaioBenedetti commented Feb 18, 2020

Generally you need to actually display the plot, so try something like

using DynamicalSystems
using Plots

ds = Systems.shinriki([-2, 0, 0.2])

pvalues = range(19, stop = 22, length = 401)
i = 1
plane = (2, 0.0)
tf = 200.0
p_index = 1

output = produce_orbitdiagram(ds, plane, i, p_index, pvalues;
tfinal = tf, Ttr = 200.0)

pyplot()
for (j, p) in enumerate(pvalues)
  display(plot(fill(p, length(output[j])), output[j], lw = 0,marker = "o", ms = 0.2, color = "black"))
end

I tried it, and the plot indeed appeared. So, the problem was not a bug, but the specific problem where I needed to add plots over the same figure. Here is the solution that I came up with:

pyplot()
fig=plot()
for (j, p) in enumerate(pvalues)
plot!(fill(p, length(output[j])), output[j], lw = 0, markershape =Symbol[:circle], ms = 1, color = "black")
end
xlabel!("$λ$"); ylabel!("$v$")
plot!(legend=false)

Thanks everyone for the help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants