Choosing not to plot

Greetings everyone,

I don’t want to plot my functions every time I run the script and I don’t want Plots to load when I’m not plotting, but I found that I can’t place the

using Plots

statement inside an if/else statement. i.e.

print("Generate a diagram as a visual check? (Yes=1, No=0): ")
YN=parse(Float64,readline())

if YN != 1
	println("No diagram.")
else
	using Plots
	plotly()

etc.etc.

The only workaround I could guess is to do the following:

print("Generate a diagram as a visual check? (Yes=1, No=0): ")
YN=parse(Float64,readline())

if YN != 1
	println("No diagram.")
	exit(0) # force exit to avoid loading the Plots module
end

using Plots
plotly()

I’m not excited about forcing the script to end, although it works for me as it’s the final step in the script.

Is there are proper way to achieve this?

P.

You should be able to use @eval using Plots.

Apologies, I meant to clarify: I actually can Plot, but I can’t reference macros.

Thanks. I’ll look that up.

FYI for anyone else - by putting the @layout statement inside the @eval the problem was solved.

...
else
   using Plots
   plotly()
   @eval l = @layout [a{0.5w} grid(2,2)]
   plot( ... layout = l)
end

:+1: