First, please quote your code: this makes it easier to run your examples and help you.
As for your question: the problem is that you need Julia to stay alive for it to display the graph. There are two ways (that I know of):
run your script like this:
sh> julia -i plotex.jl
this will make the REPL stay alive after having executed your file. You can look at your plot, and kill the REPL manually afterwards as usual, using for example Ctrl+d or exit().
add readline() at the end of your script. This will make Julia wait until you press RET before it exits (and makes your plot disappear)
Adding gui() or display(plot1) alone did not make the plot window stay open. Nor did readline() . Adding readline() just made the terminal hang until i hit RETURN.
However adding gui() and executing the script with
$julia -i plotex.jl did the trick.
I will post another question under a performance heading as well. When I type the code manually into REPL the plot shows immediately after the last line. When I run the code as a script from a terminal it takes 27 seconds for the plot to appear! Can anyone explain this?