This page looks best with JavaScript enabled

Julia plotting packages

 ·  ☕ 2 min read  ·  👽 PolyMax

Plots

1
2
3
4
5
6
# pkg> add Plots PyPlot GR UnicodePlots
using Plots
# pyplot()  # PyPlot backend

eq(d) = -7.65 * sind(d) + 9.87 * sind(2d + 206)
plot(eq, 1:365)

svg

UnicodePlots

1
2
3
4
5
# add UnicodePlots
using UnicodePlots

FirstLinePlot = lineplot([1, 2, 3, 7], [1, 2, -5, 7], title = "First Line Plot", border = :dotted)
UnicodePlots.savefig(FirstLinePlot, "FirstLinePlot.txt")

png

1
2
FirstDensityPlot = densityplot(collect(1:100), randn(100), border = :dotted)
UnicodePlots.savefig(FirstDensityPlot, "FirstDensityPlot.txt")

png

VegaLite

1
2
3
4
5
6
# add VegaLite
using VegaLite

X = ["Monday", "Tuesday", "Wednesday", "Thrusday", "Friday","Saturday","Sunday"]
Y = [11, 11, 15, 13, 12, 13, 10]
P = pie(X, Y)

svg

Winston

1
2
3
4
5
6
7
8
9
using Winston

x = range(0, stop = 3pi, length = 100);
c = cos.(x);
s = sin.(x);
p = FramedPlot(title = "Winston Graphics!", xlabel = "\\Sigma x^2_i", ylabel = "\\Theta_i")
add(p, FillBetween(x, c, x, s))
add(p, Curve(x, c, color = "black"))
add(p, Curve(x, s, color = "red"))

png

Gadfly

1
2
3
4
5
using Gadfly
using RDatasets

iris = dataset("datasets", "iris");
Gadfly.plot(iris, x = :SepalLength, y = :SepalWidth, Geom.point)

svg

1
Gadfly.plot(iris, x = :SepalLength, y = :SepalWidth, Geom.point, Geom.line)

svg

1
Gadfly.plot(iris, x = :SepalLength, y = :SepalWidth, color = :Species, Geom.point)

svg

Compose

1
2
3
4
using Compose

composition = compose(compose(context(), rectangle()), fill("tomato"))
draw(SVG("simple.svg", 6cm, 6cm), composition)

svg

1
2
3
composition = compose(context(), (context(), Compose.circle(), fill("bisque")), 
                      (context(), rectangle(), fill("tomato")))
composition |> SVG("simple2.svg")

svg

PyPlot

1
2
3
4
5
6
7
using Conda
Conda.add("matplotlib")

using PyPlot
x = range(0; stop = 2*pi, length = 500);
y = sin.(3 * x + 4 * cos.(2 * x));
PyPlot.plot(x, y, color = "blue", linewidth = 1.0, linestyle = "--")

png

1
surf(rand(20, 30))

png

Gaston

1
2
3
4
5
using PGFPlots

R = Axis([Plots.Linear(x->sin(3x)*exp(-0.3x), (0,8), legendentry = L"$\sin(3x)*exp(-0.3x)$"), 
         Plots.Linear(x->sqrt(x)/(1+x^2), (0,8), legendentry = L"$\sqrt{2x}/(1+x^2)$")])
save("Plot_LinearPGF.svg", R)

svg


  1. Summary from《LEARN JULIA PROGRAMMING》
Share on

Guankui Liu
WRITTEN BY
PolyMax
My research interests include statistics, computer vision and ecological modelling.