user1834153
user1834153

Reputation: 330

Plotting with Julia multiple graphs in a loop or function

I'm using Atom and Julia to plot a good number of graphs. I have a code like this:

function plotnetwork(A)
  for i=1:size(A,3)
    p,t=findn(A[:,:,i]
    graphplot(p,t)
  end
return
end

where graphplot is grom PlotRecipes: https://github.com/JuliaPlots/PlotRecipes.jl

I have the following problems: using this code as a function doesn't plot anything (like if the plots where local variables) and even putting this loop in my main only outputs a single plot in a single window.

What I desire is multiple windows with one plot each, I think the command push may be what I need but I didn't find much online.

Upvotes: 1

Views: 4570

Answers (1)

Chris Rackauckas
Chris Rackauckas

Reputation: 19132

You never displayed the plot. Plots are normally displayed on return in the REPL, but since scripts and functions don't have implicit returns, this isn't happening. So add display(plot(...)). Or, save the array of plot objects (push!(ps,plot(...))) and return the array of plots so you can plot(ps[i]) for separate windows.

Upvotes: 3

Related Questions