## 2-D Plotting ## At the time of writing this techical report, plotting in Julia is not quite straighforward. There are several packages with varying ## capabilities that grant flexibility in ## choosing the underlying plotting device. PyPlot seems to be one of the popular packages that uses Python's matplotlib package. ## In order to use this package, Julia must have access to a certain Python shared library. On maya, this can be done by starting ## Julia as: >LD_LIBRARY_PATH=/usr/cluster/contrib/julia/0.5.0/share/julia/site/v0.5/Conda/deps/usr/lib/ julia using PyPlot plt = PyPlot; # Read the data from a dat file. datt = readdlm("../matlabdata.dat"); # Basic plotting of y vs x plt.figure(); plt.plot(datt[:,1],datt[:,2]); plt.savefig("julia_fig_1.png"); x1 = collect(-2*pi:4*pi/1024:2*pi); y1 = x1 .* sin(x1.^2); # now a better plot with title, grid etc. plt.figure(); plt.plot(x1, y1); plt.ylabel("f(x)"); plt.xlabel("x"); plt.title("Graph of f(x)=x sin(x^2)"); plt.grid(true); plt.savefig("julia_fig_2.png");