Plotting and returning values from within a function

You haven’t mentioned which plotting package you’re using, but if you’re using Plots.jl, try adding this after the call to plot

display(current())

In the REPL, the plot is automatically shown if the plot is returned since the show method for plots is called automatically. If the plot is not returned from the function, you can instead manaully force the display. Sometimes it also works to call

plot(x, y, show=true)

and you can also do

fig = plot(x, y)
display(fig)
1 Like