Basic plots using Gadfly.jl
Boxplot
x = randn(300);
y = randn(400) .+ 1.6;
z = randn(320) .- 2.2;
plot(x=repeat(["alpha"], 300), y = x, Geom.boxplot)
plot(
x=vcat(
repeat(["x"], length(x)),
repeat(["y"], length(y)),
repeat(["z"], length(z))),
y = vcat(x, y, z),
Geom.boxplot
)
Density
dat = DataFrame(key = vcat(
repeat(["x"], length(x)),
repeat(["y"], length(y)),
repeat(["z"], length(z))),
val = vcat(x, y, z));
plot(dat, x = :val, color = :key, Geom.density)
Histogram
plot(x=x, Geom.histogram)
plot(dat, x = :val, color = :key, Geom.histogram)
Scatter
x = randn(300);
y = 3 .+ x.^3 + randn(300);
y2 = 4 .+ x.^2 + randn(300);
plot(x=x, y=y, Geom.point)
dat = DataFrame(
x = repeat(x, 2),
key = vcat(repeat(["y"], 300), repeat(["y2"], 300)),
val = vcat(y, y2)
);
plot(dat, x=:x, y=:val, color=:key, Geom.point)
Add a smoother with Geom.smooth
plot(dat, x=:x, y=:val, color=:key, Geom.point, Geom.smooth)
Barplot
x = ["alpha", "beta", "gamma"];
y = [3, 9, 5];
y2 = [5, 8, 7];
dat = DataFrame(
x = repeat(x, 2),
key = vcat(repeat(["y"], 3), repeat(["y2"], 3)),
val = vcat(y, y2)
);
plot(dat, x=:x, y=:val, color=:key, Geom.bar)