In [3]:
# Julia using matplotlib
using PyPlot
x = linspace(0, 2*pi, 1000); # use the julia linspace
y = sin(3 * x + 4 * cos(2 * x)); # use the numpy cosine and julia sine
subplots(figsize=(3,3))
plot(x, y, color="red", linewidth=2.0, linestyle="--")
ylabel("the y axis")
xlabel("the x axis")
title("a sinusoidally-modulated sinusoid")
Out[3]:
In [4]:
# Julia using matplotlib and numpy (and whatever you want)
using PyPlot
using PyCall
@pyimport matplotlib.pyplot as plt
@pyimport numpy as np
# Note how we mix numpy and julia:
t = linspace(0, 2*pi, 1000); # use the julia linspace
s = sin(3 * t + 4 * np.cos(2 * t)); # use the numpy cosine and julia sine
fig = plt.gcf() # **** WATCH THIS VARIABLE ****
plt.subplots(figsize=(3,3))
plt.plot(t, s, color="red", linewidth=2.0, linestyle="--")
Out[4]:
In [5]:
#MANDEL Mandelbrot set.
using PyPlot
mc = 301
x = linspace(-2.1, 0.6, mc)'
y = linspace(-1.1, 1.1, mc)
C = complex(repmat(x, mc), repmat(y, 1, mc))
Z_max = 1e6
it_max = 50
Z = C
for k in 1:it_max
Z = Z .^ 2 + C
end
subplots(figsize=(3,3))
contourf(x, y, (abs(Z) .< Z_max))
title("Figure 1.7 Mandelbrot Set")
Out[5]:
In [6]:
#list of current Julia Packages: you can add more via Pkg.add("NameOfPackage")
Pkg.status()
In [ ]: