using Gadfly
set_default_plot_size(21cm, 8cm)
palettef = Scale.lab_gradient("darkgreen", "orange", "blue")
p1 = plot(x=1:10, y=rand(10), color=1:10, Geom.point,
Scale.color_continuous(colormap=palettef, minvalue=0, maxvalue=10),
Guide.title("Scale.color_continuous, Theme(alphas=[0.5])"),
Theme(alphas=[0.5], continuous_highlight_color=identity,
point_size=2mm)
)
p2 = plot(x=1:10, y=rand(10), alpha=1:10, Geom.point,
Scale.alpha_continuous(minvalue=0, maxvalue=10),
Guide.title("Scale.alpha_continuous, Theme(default_color=\"blue\")"),
Theme(default_color="blue", discrete_highlight_color=c->"gray",
point_size=2mm)
)
hstack(p1, p2)
x
-12.5
-10.0
-7.5
-5.0
-2.5
0.0
2.5
5.0
7.5
10.0
12.5
15.0
17.5
20.0
22.5
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-10
0
10
20
-10.0
-9.5
-9.0
-8.5
-8.0
-7.5
-7.0
-6.5
-6.0
-5.5
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
10.5
11.0
11.5
12.0
12.5
13.0
13.5
14.0
14.5
15.0
15.5
16.0
16.5
17.0
17.5
18.0
18.5
19.0
19.5
20.0
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-1.25
-1.00
-0.75
-0.50
-0.25
0.00
0.25
0.50
0.75
1.00
1.25
1.50
1.75
2.00
2.25
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
y
Scale.alpha_continuous, Theme(default_color="blue")
x
-12.5
-10.0
-7.5
-5.0
-2.5
0.0
2.5
5.0
7.5
10.0
12.5
15.0
17.5
20.0
22.5
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-10
0
10
20
-10.0
-9.5
-9.0
-8.5
-8.0
-7.5
-7.0
-6.5
-6.0
-5.5
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
10.5
11.0
11.5
12.0
12.5
13.0
13.5
14.0
14.5
15.0
15.5
16.0
16.5
17.0
17.5
18.0
18.5
19.0
19.5
20.0
10
5
0
Color
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-1.2
-1.0
-0.8
-0.6
-0.4
-0.2
0.0
0.2
0.4
0.6
0.8
1.0
1.2
1.4
1.6
1.8
2.0
2.2
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
y
Scale.color_continuous, Theme(alphas=[0.5])
using DataFrames, Gadfly
set_default_plot_size(21cm, 8cm)
D = DataFrame(x=1:6, y=rand(6), Shape=repeat(["a","b","c"], outer=2))
coord = Coord.cartesian(xmin=0, xmax=7, ymin=0, ymax=1.0)
p1 = plot(D, x=:x, y=:y, color=:x, coord,
Scale.color_discrete, Geom.point, Geom.hair,
Guide.title("Scale.color_discrete, Theme(alphas=[0.5])"),
Theme(alphas=[0.5], discrete_highlight_color=identity,
point_size=2mm)
)
p2 = plot(D, x=:x, y=:y, alpha=:x, shape=:Shape, coord,
Scale.alpha_discrete, Geom.point, Geom.hair,
Guide.title("Scale.alpha_discrete, Theme(default_color=\"green\")"),
Theme(default_color="green", discrete_highlight_color=c->"gray",
point_size=2mm, alphas=[0.0,0.2,0.4,0.6,0.8,1.0])
)
hstack(p1,p2)
x
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-7.0
-6.5
-6.0
-5.5
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
10.5
11.0
11.5
12.0
12.5
13.0
13.5
14.0
-10
0
10
20
-7.0
-6.5
-6.0
-5.5
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
10.5
11.0
11.5
12.0
12.5
13.0
13.5
14.0
a
b
c
Shape
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
y
Scale.alpha_discrete, Theme(default_color="green")
x
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-7.0
-6.5
-6.0
-5.5
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
10.5
11.0
11.5
12.0
12.5
13.0
13.5
14.0
-10
0
10
20
-7.0
-6.5
-6.0
-5.5
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
10.5
11.0
11.5
12.0
12.5
13.0
13.5
14.0
1
2
3
4
5
6
x
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
y
Scale.color_discrete, Theme(alphas=[0.5])
using Gadfly
set_default_plot_size(21cm, 8cm)
xdata, ydata, cdata = rand(12), rand(12), rand(12)
p1 = plot(x=xdata, y=ydata, color=cdata)
p2 = plot(x=xdata, y=ydata, color=cdata,
Scale.color_continuous(minvalue=-1, maxvalue=1))
hstack(p1,p2)
x
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
-1.0
-0.5
0.0
0.5
1.0
Color
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-1.2
-1.0
-0.8
-0.6
-0.4
-0.2
0.0
0.2
0.4
0.6
0.8
1.0
1.2
1.4
1.6
1.8
2.0
2.2
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
y
x
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
0.0
0.5
1.0
Color
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-1.2
-1.0
-0.8
-0.6
-0.4
-0.2
0.0
0.2
0.4
0.6
0.8
1.0
1.2
1.4
1.6
1.8
2.0
2.2
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
y
using Gadfly, Colors
set_default_plot_size(21cm, 8cm)
x = repeat((1:10).-0.5, inner=[10])
y = repeat((1:10).-0.5, outer=[10])
p1 = plot(x=x, y=y, color=x+y, Geom.rectbin,
Scale.color_continuous(colormap=p->RGB(0,p,0)))
p2 = plot(x=x, y=y, color=x+y, Geom.rectbin,
Scale.color_continuous(colormap=Scale.lab_gradient("green", "white", "red")))
p3 = plot(x=x, y=y, color=x+y, Geom.rectbin,
Scale.color_continuous(colormap=p->RGB(0,p,0), minvalue=-20))
hstack(p1,p2,p3)
x
-15
-10
-5
0
5
10
15
20
25
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-10
0
10
20
-10.0
-9.5
-9.0
-8.5
-8.0
-7.5
-7.0
-6.5
-6.0
-5.5
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
10.5
11.0
11.5
12.0
12.5
13.0
13.5
14.0
14.5
15.0
15.5
16.0
16.5
17.0
17.5
18.0
18.5
19.0
19.5
20.0
-20
0
20
-10
10
Color
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-15
-10
-5
0
5
10
15
20
25
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-10
0
10
20
-10.0
-9.5
-9.0
-8.5
-8.0
-7.5
-7.0
-6.5
-6.0
-5.5
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
10.5
11.0
11.5
12.0
12.5
13.0
13.5
14.0
14.5
15.0
15.5
16.0
16.5
17.0
17.5
18.0
18.5
19.0
19.5
20.0
y
x
-15
-10
-5
0
5
10
15
20
25
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-10
0
10
20
-10.0
-9.5
-9.0
-8.5
-8.0
-7.5
-7.0
-6.5
-6.0
-5.5
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
10.5
11.0
11.5
12.0
12.5
13.0
13.5
14.0
14.5
15.0
15.5
16.0
16.5
17.0
17.5
18.0
18.5
19.0
19.5
20.0
10
5
15
20
1
Color
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-15
-10
-5
0
5
10
15
20
25
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-10
0
10
20
-10.0
-9.5
-9.0
-8.5
-8.0
-7.5
-7.0
-6.5
-6.0
-5.5
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
10.5
11.0
11.5
12.0
12.5
13.0
13.5
14.0
14.5
15.0
15.5
16.0
16.5
17.0
17.5
18.0
18.5
19.0
19.5
20.0
y
x
-15
-10
-5
0
5
10
15
20
25
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-10
0
10
20
-10.0
-9.5
-9.0
-8.5
-8.0
-7.5
-7.0
-6.5
-6.0
-5.5
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
10.5
11.0
11.5
12.0
12.5
13.0
13.5
14.0
14.5
15.0
15.5
16.0
16.5
17.0
17.5
18.0
18.5
19.0
19.5
20.0
1
20
10
15
5
Color
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-15
-10
-5
0
5
10
15
20
25
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-10
0
10
20
-10.0
-9.5
-9.0
-8.5
-8.0
-7.5
-7.0
-6.5
-6.0
-5.5
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
10.5
11.0
11.5
12.0
12.5
13.0
13.5
14.0
14.5
15.0
15.5
16.0
16.5
17.0
17.5
18.0
18.5
19.0
19.5
20.0
y
using Gadfly, Colors, RDatasets, Random
set_default_plot_size(14cm, 8cm)
Random.seed!(1234)
function gen_colors(n)
cs = distinguishable_colors(n,
[colorant"#FE4365", colorant"#eca25c"],
lchoices = Float64[58, 45, 72.5, 90],
transform = c -> deuteranopic(c, 0.1),
cchoices = Float64[20,40],
hchoices = [75,51,35,120,180,210,270,310])
convert(Vector{Color}, cs)
end
iris = dataset("datasets", "iris")
plot(iris, x=:SepalLength, y=:SepalWidth, color=:Species,
Geom.point, Scale.color_discrete(gen_colors))
SepalLength
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
10.5
11.0
11.5
12.0
0
5
10
15
0.0
0.2
0.4
0.6
0.8
1.0
1.2
1.4
1.6
1.8
2.0
2.2
2.4
2.6
2.8
3.0
3.2
3.4
3.6
3.8
4.0
4.2
4.4
4.6
4.8
5.0
5.2
5.4
5.6
5.8
6.0
6.2
6.4
6.6
6.8
7.0
7.2
7.4
7.6
7.8
8.0
8.2
8.4
8.6
8.8
9.0
9.2
9.4
9.6
9.8
10.0
10.2
10.4
10.6
10.8
11.0
11.2
11.4
11.6
11.8
12.0
setosa
versicolor
virginica
Species
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
-0.6
-0.4
-0.2
0.0
0.2
0.4
0.6
0.8
1.0
1.2
1.4
1.6
1.8
2.0
2.2
2.4
2.6
2.8
3.0
3.2
3.4
3.6
3.8
4.0
4.2
4.4
4.6
4.8
5.0
5.2
5.4
5.6
5.8
6.0
6.2
6.4
6.6
6.8
7.0
-2.5
0.0
2.5
5.0
7.5
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
2.1
2.2
2.3
2.4
2.5
2.6
2.7
2.8
2.9
3.0
3.1
3.2
3.3
3.4
3.5
3.6
3.7
3.8
3.9
4.0
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5.0
5.1
5.2
5.3
5.4
5.5
5.6
5.7
5.8
5.9
6.0
6.1
6.2
6.3
6.4
6.5
6.6
6.7
6.8
6.9
7.0
SepalWidth
using Gadfly, Random
set_default_plot_size(21cm, 8cm)
Random.seed!(1234)
xdata, ydata = rand(12), rand(12)
p1 = plot(x=xdata, y=ydata, color=repeat([1,2,3], outer=[4]))
p2 = plot(x=xdata, y=ydata, color=repeat([1,2,3], outer=[4]), Scale.color_discrete)
hstack(p1,p2)
x
-1.25
-1.00
-0.75
-0.50
-0.25
0.00
0.25
0.50
0.75
1.00
1.25
1.50
1.75
2.00
2.25
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
1
2
3
Color
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
y
x
-1.25
-1.00
-0.75
-0.50
-0.25
0.00
0.25
0.50
0.75
1.00
1.25
1.50
1.75
2.00
2.25
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
1.0
1.5
2.0
2.5
3.0
Color
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
y
using Gadfly, Random
Random.seed!(12345)
set_default_plot_size(14cm, 8cm)
plot(x=rand(12), y=rand(12), color=repeat(["a","b","c"], outer=[4]),
Scale.color_discrete_manual("red","purple","green"))
x
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
a
b
c
Color
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
y
using Gadfly, RDatasets, DataFrames
set_default_plot_size(14cm, 8cm)
hecolor = dataset("datasets","HairEyeColor")
D = combine(groupby(hecolor, [:Eye,:Sex]), :Freq=>sum=>:Frequency)
palette = ["brown","blue","tan","green"] # Is there a hazel color?
pa = plot(D, x=:Sex, y=:Frequency, color=:Eye, Geom.bar(position=:stack),
Scale.color_discrete_manual(palette...))
pb = plot(D, x=:Sex, y=:Frequency, color=:Eye, Geom.bar(position=:stack),
Scale.color_discrete_manual(palette[4:-1:1]..., order=[4,3,2,1]))
hstack(pa,pb)
Sex
Male
Female
Green
Hazel
Blue
Brown
Eye
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-500
-400
-300
-200
-100
0
100
200
300
400
500
600
700
800
900
-400
-350
-300
-250
-200
-150
-100
-50
0
50
100
150
200
250
300
350
400
450
500
550
600
650
700
750
800
-500
0
500
1000
-400
-380
-360
-340
-320
-300
-280
-260
-240
-220
-200
-180
-160
-140
-120
-100
-80
-60
-40
-20
0
20
40
60
80
100
120
140
160
180
200
220
240
260
280
300
320
340
360
380
400
420
440
460
480
500
520
540
560
580
600
620
640
660
680
700
720
740
760
780
800
Frequency
Sex
Male
Female
Brown
Blue
Hazel
Green
Eye
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-500
-400
-300
-200
-100
0
100
200
300
400
500
600
700
800
900
-400
-350
-300
-250
-200
-150
-100
-50
0
50
100
150
200
250
300
350
400
450
500
550
600
650
700
750
800
-500
0
500
1000
-400
-380
-360
-340
-320
-300
-280
-260
-240
-220
-200
-180
-160
-140
-120
-100
-80
-60
-40
-20
0
20
40
60
80
100
120
140
160
180
200
220
240
260
280
300
320
340
360
380
400
420
440
460
480
500
520
540
560
580
600
620
640
660
680
700
720
740
760
780
800
Frequency
using DataFrames, Gadfly, RDatasets
set_default_plot_size(18cm, 8cm)
labs = ["exp", "sqrt", "log", "winsor", "linear"]
funcs = [x->60*(1.0.-exp.(-0.2*x)), x->sqrt.(x)*10, x->log.(x)*10,
x->clamp.(x,5,26), x->x*0.6]
x = [1.0:30;]
D = vcat([DataFrame(x=x, y=f(x), linev=l) for (f,l) in zip(funcs, labs)]...)
D[134:136,:y] .= NaN
p1 = plot(D, x=:x, y=:y, linestyle=:linev, Geom.line)
p2 = plot(dataset("datasets", "CO2"), x=:Conc, y=:Uptake,
group=:Plant, linestyle=:Treatment, color=:Type, Geom.line,
Scale.linestyle_discrete(order=[2,1]),
Theme(key_position=:top, key_title_font_size=-8mm))
hstack(p1,p2)
Conc
-1250
-1000
-750
-500
-250
0
250
500
750
1000
1250
1500
1750
2000
2250
-1000
-900
-800
-700
-600
-500
-400
-300
-200
-100
0
100
200
300
400
500
600
700
800
900
1000
1100
1200
1300
1400
1500
1600
1700
1800
1900
2000
-1000
0
1000
2000
-1000
-950
-900
-850
-800
-750
-700
-650
-600
-550
-500
-450
-400
-350
-300
-250
-200
-150
-100
-50
0
50
100
150
200
250
300
350
400
450
500
550
600
650
700
750
800
850
900
950
1000
1050
1100
1150
1200
1250
1300
1350
1400
1450
1500
1550
1600
1650
1700
1750
1800
1850
1900
1950
2000
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-60
-50
-40
-30
-20
-10
0
10
20
30
40
50
60
70
80
90
100
110
-50
-45
-40
-35
-30
-25
-20
-15
-10
-5
0
5
10
15
20
25
30
35
40
45
50
55
60
65
70
75
80
85
90
95
100
-50
0
50
100
-50
-48
-46
-44
-42
-40
-38
-36
-34
-32
-30
-28
-26
-24
-22
-20
-18
-16
-14
-12
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
86
88
90
92
94
96
98
100
Uptake
Mississippi
Quebec
Type
x
-40
-30
-20
-10
0
10
20
30
40
50
60
70
-30
-28
-26
-24
-22
-20
-18
-16
-14
-12
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
-30
0
30
60
-30
-29
-28
-27
-26
-25
-24
-23
-22
-21
-20
-19
-18
-17
-16
-15
-14
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-70
-60
-50
-40
-30
-20
-10
0
10
20
30
40
50
60
70
80
90
100
110
120
130
-60
-55
-50
-45
-40
-35
-30
-25
-20
-15
-10
-5
0
5
10
15
20
25
30
35
40
45
50
55
60
65
70
75
80
85
90
95
100
105
110
115
120
-100
0
100
200
-60
-58
-56
-54
-52
-50
-48
-46
-44
-42
-40
-38
-36
-34
-32
-30
-28
-26
-24
-22
-20
-18
-16
-14
-12
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
86
88
90
92
94
96
98
100
102
104
106
108
110
112
114
116
118
120
y
using Gadfly, RDatasets, Statistics
set_default_plot_size(14cm, 8cm)
tips = dataset("reshape2", "tips")
tipsm = combine(groupby(tips, [:Day, :Sex]), [:TotalBill, :Tip].=>mean)
plot(tipsm, Geom.point,
x=:TotalBill_mean, y=:Tip_mean, color=:Sex, shape=:Day,
layer(x=:TotalBill_mean, y=:Tip_mean, group=:Day, Geom.line,
color=[colorant"gray"]),
Scale.shape_discrete(levels=["Thur","Fri","Sat","Sun"]),
Guide.shapekey(pos=[14.5, 3.8]), Guide.colorkey(pos=[16, 3.87]),
Theme(discrete_highlight_color=identity, alphas=[0.1],
point_size=5pt, key_swatch_color="slategray")
)
TotalBill_mean
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
0
10
20
30
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
10.5
11.0
11.5
12.0
12.5
13.0
13.5
14.0
14.5
15.0
15.5
16.0
16.5
17.0
17.5
18.0
18.5
19.0
19.5
20.0
20.5
21.0
21.5
22.0
22.5
23.0
23.5
24.0
24.5
25.0
25.5
26.0
26.5
27.0
27.5
28.0
28.5
29.0
29.5
30.0
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
Female
Male
Sex
Thur
Fri
Sat
Sun
Day
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
2.1
2.2
2.3
2.4
2.5
2.6
2.7
2.8
2.9
3.0
3.1
3.2
3.3
3.4
3.5
3.6
3.7
3.8
3.9
4.0
4.1
4.2
4.3
4.4
4.5
1
2
3
4
5
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
2.05
2.10
2.15
2.20
2.25
2.30
2.35
2.40
2.45
2.50
2.55
2.60
2.65
2.70
2.75
2.80
2.85
2.90
2.95
3.00
3.05
3.10
3.15
3.20
3.25
3.30
3.35
3.40
3.45
3.50
3.55
3.60
3.65
3.70
3.75
3.80
3.85
3.90
3.95
4.00
4.05
4.10
4.15
4.20
4.25
4.30
4.35
4.40
4.45
4.50
Tip_mean
using Gadfly, RDatasets
set_default_plot_size(21cm, 8cm)
aq = dropmissing(dataset("datasets","airquality"))
aq = filter(x-> 7≤x.Month≤9, aq)
sizemap(p::Float64; min=0.75mm, max=3mm) = min + p*(max-min)
labels = ["July", "August", "September"]
coord = Coord.cartesian(xmin=0, xmax=32, ymin=0, ymax=160)
plot(aq, x=:Day, y=:Ozone, color=:Month, size=:Wind,
coord, Scale.color_discrete,
Guide.colorkey(title="", labels=labels, pos=[2,240]),
Scale.size_area(sizemap, minvalue=4, maxvalue=16),
Guide.sizekey(title="Wind (mph)"), Guide.xlabel("Day of Month"),
Theme(key_swatch_shape=Shape.circle, key_swatch_color="gray",
discrete_highlight_color=identity, alphas=[0.5])
)
Day of Month
-50
-40
-30
-20
-10
0
10
20
30
40
50
60
70
80
90
-32
-30
-28
-26
-24
-22
-20
-18
-16
-14
-12
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
-50
0
50
100
-32
-31
-30
-29
-28
-27
-26
-25
-24
-23
-22
-21
-20
-19
-18
-17
-16
-15
-14
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
4
6
8
10
12
14
16
Wind (mph)
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
July
August
September
-180
-160
-140
-120
-100
-80
-60
-40
-20
0
20
40
60
80
100
120
140
160
180
200
220
240
260
280
300
320
340
-160
-150
-140
-130
-120
-110
-100
-90
-80
-70
-60
-50
-40
-30
-20
-10
0
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
190
200
210
220
230
240
250
260
270
280
290
300
310
320
-200
0
200
400
-160
-155
-150
-145
-140
-135
-130
-125
-120
-115
-110
-105
-100
-95
-90
-85
-80
-75
-70
-65
-60
-55
-50
-45
-40
-35
-30
-25
-20
-15
-10
-5
0
5
10
15
20
25
30
35
40
45
50
55
60
65
70
75
80
85
90
95
100
105
110
115
120
125
130
135
140
145
150
155
160
165
170
175
180
185
190
195
200
205
210
215
220
225
230
235
240
245
250
255
260
265
270
275
280
285
290
295
300
305
310
315
320
Ozone
using Compose, Gadfly, RDatasets
set_default_plot_size(14cm, 8cm)
D = groupby(dataset("datasets", "Titanic"), :Class)
Titanic = combine(D, :, :Freq=>(c->100*c./sum(c))=>:prcnt)
filter!(:Survived=>x->x=="Yes", Titanic)
sizemap = n->range(4pt, 12pt, length=n)
plot(Titanic, Scale.x_log10, Scale.y_log10,
x=:Freq, y=:prcnt, size=:Class, color=:Age, shape=:Sex,
Scale.size_discrete2(sizemap, levels=["1st","2nd","3rd","Crew"]),
Guide.colorkey(pos=[0.1, -0.3h]), Guide.shapekey(pos=[0.5, -0.31h]),
Guide.ylabel("% of Passenger Class"),
Theme(discrete_highlight_color=identity, alphas=[0.1], key_swatch_color="grey")
)
Freq
10-3.0
10-2.5
10-2.0
10-1.5
10-1.0
10-0.5
100.0
100.5
101.0
101.5
102.0
102.5
103.0
103.5
104.0
104.5
105.0
105.5
10-2.6
10-2.4
10-2.2
10-2.0
10-1.8
10-1.6
10-1.4
10-1.2
10-1.0
10-0.8
10-0.6
10-0.4
10-0.2
100.0
100.2
100.4
100.6
100.8
101.0
101.2
101.4
101.6
101.8
102.0
102.2
102.4
102.6
102.8
103.0
103.2
103.4
103.6
103.8
104.0
104.2
104.4
104.6
104.8
105.0
10-2.5
100.0
102.5
105.0
10-2.5
10-2.4
10-2.3
10-2.2
10-2.1
10-2.0
10-1.9
10-1.8
10-1.7
10-1.6
10-1.5
10-1.4
10-1.3
10-1.2
10-1.1
10-1.0
10-0.9
10-0.8
10-0.7
10-0.6
10-0.5
10-0.4
10-0.3
10-0.2
10-0.1
100.0
100.1
100.2
100.3
100.4
100.5
100.6
100.7
100.8
100.9
101.0
101.1
101.2
101.3
101.4
101.5
101.6
101.7
101.8
101.9
102.0
102.1
102.2
102.3
102.4
102.5
102.6
102.7
102.8
102.9
103.0
103.1
103.2
103.3
103.4
103.5
103.6
103.7
103.8
103.9
104.0
104.1
104.2
104.3
104.4
104.5
104.6
104.7
104.8
104.9
105.0
1st
2nd
3rd
Crew
Class
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
Male
Female
Sex
Child
Adult
Age
10-5
10-4
10-3
10-2
10-1
100
101
102
103
104
105
106
10-4.0
10-3.8
10-3.6
10-3.4
10-3.2
10-3.0
10-2.8
10-2.6
10-2.4
10-2.2
10-2.0
10-1.8
10-1.6
10-1.4
10-1.2
10-1.0
10-0.8
10-0.6
10-0.4
10-0.2
100.0
100.2
100.4
100.6
100.8
101.0
101.2
101.4
101.6
101.8
102.0
102.2
102.4
102.6
102.8
103.0
103.2
103.4
103.6
103.8
104.0
104.2
104.4
104.6
104.8
105.0
10-5
100
105
10-4.0
10-3.9
10-3.8
10-3.7
10-3.6
10-3.5
10-3.4
10-3.3
10-3.2
10-3.1
10-3.0
10-2.9
10-2.8
10-2.7
10-2.6
10-2.5
10-2.4
10-2.3
10-2.2
10-2.1
10-2.0
10-1.9
10-1.8
10-1.7
10-1.6
10-1.5
10-1.4
10-1.3
10-1.2
10-1.1
10-1.0
10-0.9
10-0.8
10-0.7
10-0.6
10-0.5
10-0.4
10-0.3
10-0.2
10-0.1
100.0
100.1
100.2
100.3
100.4
100.5
100.6
100.7
100.8
100.9
101.0
101.1
101.2
101.3
101.4
101.5
101.6
101.7
101.8
101.9
102.0
102.1
102.2
102.3
102.4
102.5
102.6
102.7
102.8
102.9
103.0
103.1
103.2
103.3
103.4
103.5
103.6
103.7
103.8
103.9
104.0
104.1
104.2
104.3
104.4
104.5
104.6
104.7
104.8
104.9
105.0
% of Passenger Class
using Gadfly, Random, Printf
set_default_plot_size(21cm, 8cm)
Random.seed!(1234)
p1 = plot(x=rand(10), y=rand(10), Scale.x_continuous(minvalue=-10, maxvalue=10))
p2 = plot(x=rand(10), y=rand(10), Scale.x_continuous(format=:scientific))
p3 = plot(x=rand(10), y=rand(10), Scale.x_continuous(labels=x -> @sprintf("%0.4f", x)))
hstack(p1,p2,p3)
x
-1.0000
-0.8000
-0.6000
-0.4000
-0.2000
0.0000
0.2000
0.4000
0.6000
0.8000
1.0000
1.2000
1.4000
1.6000
1.8000
-0.8500
-0.8000
-0.7500
-0.7000
-0.6500
-0.6000
-0.5500
-0.5000
-0.4500
-0.4000
-0.3500
-0.3000
-0.2500
-0.2000
-0.1500
-0.1000
-0.0500
0.0000
0.0500
0.1000
0.1500
0.2000
0.2500
0.3000
0.3500
0.4000
0.4500
0.5000
0.5500
0.6000
0.6500
0.7000
0.7500
0.8000
0.8500
0.9000
0.9500
1.0000
1.0500
1.1000
1.1500
1.2000
1.2500
1.3000
1.3500
1.4000
1.4500
1.5000
1.5500
1.6000
-1.0000
0.0000
1.0000
2.0000
-0.8500
-0.8000
-0.7500
-0.7000
-0.6500
-0.6000
-0.5500
-0.5000
-0.4500
-0.4000
-0.3500
-0.3000
-0.2500
-0.2000
-0.1500
-0.1000
-0.0500
0.0000
0.0500
0.1000
0.1500
0.2000
0.2500
0.3000
0.3500
0.4000
0.4500
0.5000
0.5500
0.6000
0.6500
0.7000
0.7500
0.8000
0.8500
0.9000
0.9500
1.0000
1.0500
1.1000
1.1500
1.2000
1.2500
1.3000
1.3500
1.4000
1.4500
1.5000
1.5500
1.6000
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-1.0
-0.8
-0.6
-0.4
-0.2
0.0
0.2
0.4
0.6
0.8
1.0
1.2
1.4
1.6
1.8
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
-1
0
1
2
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
y
x
-1.50×10⁰
-1.00×10⁰
-5.00×10⁻¹
0
5.00×10⁻¹
1.00×10⁰
1.50×10⁰
2.00×10⁰
2.50×10⁰
-1.00×10⁰
-9.00×10⁻¹
-8.00×10⁻¹
-7.00×10⁻¹
-6.00×10⁻¹
-5.00×10⁻¹
-4.00×10⁻¹
-3.00×10⁻¹
-2.00×10⁻¹
-1.00×10⁻¹
0
1.00×10⁻¹
2.00×10⁻¹
3.00×10⁻¹
4.00×10⁻¹
5.00×10⁻¹
6.00×10⁻¹
7.00×10⁻¹
8.00×10⁻¹
9.00×10⁻¹
1.00×10⁰
1.10×10⁰
1.20×10⁰
1.30×10⁰
1.40×10⁰
1.50×10⁰
1.60×10⁰
1.70×10⁰
1.80×10⁰
1.90×10⁰
2.00×10⁰
-1.0×10⁰
0
1.0×10⁰
2.0×10⁰
-1.000×10⁰
-9.500×10⁻¹
-9.000×10⁻¹
-8.500×10⁻¹
-8.000×10⁻¹
-7.500×10⁻¹
-7.000×10⁻¹
-6.500×10⁻¹
-6.000×10⁻¹
-5.500×10⁻¹
-5.000×10⁻¹
-4.500×10⁻¹
-4.000×10⁻¹
-3.500×10⁻¹
-3.000×10⁻¹
-2.500×10⁻¹
-2.000×10⁻¹
-1.500×10⁻¹
-1.000×10⁻¹
-5.000×10⁻²
0
5.000×10⁻²
1.000×10⁻¹
1.500×10⁻¹
2.000×10⁻¹
2.500×10⁻¹
3.000×10⁻¹
3.500×10⁻¹
4.000×10⁻¹
4.500×10⁻¹
5.000×10⁻¹
5.500×10⁻¹
6.000×10⁻¹
6.500×10⁻¹
7.000×10⁻¹
7.500×10⁻¹
8.000×10⁻¹
8.500×10⁻¹
9.000×10⁻¹
9.500×10⁻¹
1.000×10⁰
1.050×10⁰
1.100×10⁰
1.150×10⁰
1.200×10⁰
1.250×10⁰
1.300×10⁰
1.350×10⁰
1.400×10⁰
1.450×10⁰
1.500×10⁰
1.550×10⁰
1.600×10⁰
1.650×10⁰
1.700×10⁰
1.750×10⁰
1.800×10⁰
1.850×10⁰
1.900×10⁰
1.950×10⁰
2.000×10⁰
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
y
x
-35
-30
-25
-20
-15
-10
-5
0
5
10
15
20
25
30
35
-30
-28
-26
-24
-22
-20
-18
-16
-14
-12
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
-40
-20
0
20
40
-30
-29
-28
-27
-26
-25
-24
-23
-22
-21
-20
-19
-18
-17
-16
-15
-14
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
y
using Gadfly, Random
set_default_plot_size(14cm, 8cm)
Random.seed!(1234)
plot(x=rand(10), y=rand(10), Scale.x_log)
x
e-4.5
e-4.0
e-3.5
e-3.0
e-2.5
e-2.0
e-1.5
e-1.0
e-0.5
e0.0
e0.5
e1.0
e1.5
e2.0
e2.5
e-4.0
e-3.8
e-3.6
e-3.4
e-3.2
e-3.0
e-2.8
e-2.6
e-2.4
e-2.2
e-2.0
e-1.8
e-1.6
e-1.4
e-1.2
e-1.0
e-0.8
e-0.6
e-0.4
e-0.2
e0.0
e0.2
e0.4
e0.6
e0.8
e1.0
e1.2
e1.4
e1.6
e1.8
e2.0
e-4
e-2
e0
e2
e-4.0
e-3.9
e-3.8
e-3.7
e-3.6
e-3.5
e-3.4
e-3.3
e-3.2
e-3.1
e-3.0
e-2.9
e-2.8
e-2.7
e-2.6
e-2.5
e-2.4
e-2.3
e-2.2
e-2.1
e-2.0
e-1.9
e-1.8
e-1.7
e-1.6
e-1.5
e-1.4
e-1.3
e-1.2
e-1.1
e-1.0
e-0.9
e-0.8
e-0.7
e-0.6
e-0.5
e-0.4
e-0.3
e-0.2
e-0.1
e0.0
e0.1
e0.2
e0.3
e0.4
e0.5
e0.6
e0.7
e0.8
e0.9
e1.0
e1.1
e1.2
e1.3
e1.4
e1.5
e1.6
e1.7
e1.8
e1.9
e2.0
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
y
using Gadfly, DataFrames, Random
set_default_plot_size(14cm, 8cm)
Random.seed!(1234)
# Treat numerical x data as categories
p1 = plot(x=rand(1:3, 20), y=rand(20), Scale.x_discrete)
# To perserve the order of the columns in the plot when plotting a DataFrame
df = DataFrame(v1 = randn(10), v2 = randn(10), v3 = randn(10))
p2 = plot(df, x=Col.index, y=Col.value, Scale.x_discrete(levels=propertynames(df)))
hstack(p1,p2)
x
v1
v2
v3
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
-6.0
-5.5
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
-6
-3
0
3
6
-6.0
-5.8
-5.6
-5.4
-5.2
-5.0
-4.8
-4.6
-4.4
-4.2
-4.0
-3.8
-3.6
-3.4
-3.2
-3.0
-2.8
-2.6
-2.4
-2.2
-2.0
-1.8
-1.6
-1.4
-1.2
-1.0
-0.8
-0.6
-0.4
-0.2
0.0
0.2
0.4
0.6
0.8
1.0
1.2
1.4
1.6
1.8
2.0
2.2
2.4
2.6
2.8
3.0
3.2
3.4
3.6
3.8
4.0
4.2
4.4
4.6
4.8
5.0
5.2
5.4
5.6
5.8
6.0
y
x
2
3
1
h,j,k,l,arrows,drag to pan
i,o,+,-,scroll,shift-drag to zoom
r,dbl-click to reset
c for coordinates
? for help
?
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
-1.0
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0
-1
0
1
2
-1.00
-0.95
-0.90
-0.85
-0.80
-0.75
-0.70
-0.65
-0.60
-0.55
-0.50
-0.45
-0.40
-0.35
-0.30
-0.25
-0.20
-0.15
-0.10
-0.05
0.00
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40
0.45
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
0.95
1.00
1.05
1.10
1.15
1.20
1.25
1.30
1.35
1.40
1.45
1.50
1.55
1.60
1.65
1.70
1.75
1.80
1.85
1.90
1.95
2.00
y
using Gadfly, RDatasets
set_default_plot_size(21cm,14cm)
# mpg = miles per gallon
mpg = dataset("ggplot2","mpg")
xlabs = Dict(4=>"4 Cyl", 6=>"6 Cyl", 8=>"8 Cyl")
ylabs = Dict("f"=>"front", "r"=>"rear", "4"=>"4-wheel")
plot(mpg[mpg.Cyl.≠5,:], x=:Cty, y=:Hwy, color=:Class,
xgroup=:Cyl, ygroup=:Drv,
Geom.subplot_grid( Coord.cartesian(xmin=10), Geom.point,
layer(slope=[1], intercept=[0], Geom.abline(color="silver", style=:dash))),
Scale.xgroup(labels=i->xlabs[i], levels=[4,6,8]),
Scale.ygroup(labels=i->ylabs[i], levels=["f","4","r"]),
Guide.xlabel("City miles/gallon by Cylinders"),
Guide.ylabel("Highway miles/gallon by Drive"),
Theme(colorkey_swatch_shape=:circle)
)
City miles/gallon by Cylinders
compact
midsize
suv
2seater
minivan
pickup
subcompact
Class
8 Cyl
6 Cyl
4 Cyl
-20
-15
-10
-5
0
5
10
15
20
25
30
35
40
45
50
55
60
65
-16
-14
-12
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
-20
0
20
40
60
-15
-14
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
-20
-15
-10
-5
0
5
10
15
20
25
30
35
40
45
50
55
60
65
-16
-14
-12
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
-20
0
20
40
60
-15
-14
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
-20
-15
-10
-5
0
5
10
15
20
25
30
35
40
45
50
55
60
65
-16
-14
-12
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
-20
0
20
40
60
-15
-14
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
-60
-50
-40
-30
-20
-10
0
10
20
30
40
50
60
70
80
90
100
110
-50
-45
-40
-35
-30
-25
-20
-15
-10
-5
0
5
10
15
20
25
30
35
40
45
50
55
60
65
70
75
80
85
90
95
100
-50
0
50
100
-50
-48
-46
-44
-42
-40
-38
-36
-34
-32
-30
-28
-26
-24
-22
-20
-18
-16
-14
-12
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
86
88
90
92
94
96
98
100
rear
-60
-50
-40
-30
-20
-10
0
10
20
30
40
50
60
70
80
90
100
110
-50
-45
-40
-35
-30
-25
-20
-15
-10
-5
0
5
10
15
20
25
30
35
40
45
50
55
60
65
70
75
80
85
90
95
100
-50
0
50
100
-50
-48
-46
-44
-42
-40
-38
-36
-34
-32
-30
-28
-26
-24
-22
-20
-18
-16
-14
-12
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
86
88
90
92
94
96
98
100
4-wheel
-60
-50
-40
-30
-20
-10
0
10
20
30
40
50
60
70
80
90
100
110
-50
-45
-40
-35
-30
-25
-20
-15
-10
-5
0
5
10
15
20
25
30
35
40
45
50
55
60
65
70
75
80
85
90
95
100
-50
0
50
100
-50
-48
-46
-44
-42
-40
-38
-36
-34
-32
-30
-28
-26
-24
-22
-20
-18
-16
-14
-12
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
86
88
90
92
94
96
98
100
front
Highway miles/gallon by Drive