using Gadfly, RDatasets, Compose, Random
Random.seed!(123)
set_default_plot_size(21cm, 8cm)
p1 = plot(dataset("ggplot2", "mpg"),
x="Cty", y="Hwy", label="Model", Geom.point, Geom.label,
intercept=[0], slope=[1], Geom.abline(color="red", style=:dash),
Guide.annotation(compose(context(), text(6,4, "y=x", hleft, vtop), fill("red"))))
x = [20*rand(20); exp(-3)]
D = DataFrame(x=x, y= exp.(-0.5*asinh.(x).+5) .+ 2*randn(length(x)))
abline = Geom.abline(color="red", style=:dash)
p2 = plot(D, x=:x, y=:y, Geom.point, Scale.x_asinh, Scale.y_log,
intercept=[148], slope=[-0.5], abline)
hstack(p1, p2)
x
sinh(-5)
sinh(-4)
sinh(-3)
sinh(-2)
sinh(-1)
sinh(0)
sinh(1)
sinh(2)
sinh(3)
sinh(4)
sinh(5)
sinh(6)
sinh(7)
sinh(8)
sinh(9)
sinh(-4.0)
sinh(-3.8)
sinh(-3.6)
sinh(-3.4)
sinh(-3.2)
sinh(-3.0)
sinh(-2.8)
sinh(-2.6)
sinh(-2.4)
sinh(-2.2)
sinh(-2.0)
sinh(-1.8)
sinh(-1.6)
sinh(-1.4)
sinh(-1.2)
sinh(-1.0)
sinh(-0.8)
sinh(-0.6)
sinh(-0.4)
sinh(-0.2)
sinh(0.0)
sinh(0.2)
sinh(0.4)
sinh(0.6)
sinh(0.8)
sinh(1.0)
sinh(1.2)
sinh(1.4)
sinh(1.6)
sinh(1.8)
sinh(2.0)
sinh(2.2)
sinh(2.4)
sinh(2.6)
sinh(2.8)
sinh(3.0)
sinh(3.2)
sinh(3.4)
sinh(3.6)
sinh(3.8)
sinh(4.0)
sinh(4.2)
sinh(4.4)
sinh(4.6)
sinh(4.8)
sinh(5.0)
sinh(5.2)
sinh(5.4)
sinh(5.6)
sinh(5.8)
sinh(6.0)
sinh(6.2)
sinh(6.4)
sinh(6.6)
sinh(6.8)
sinh(7.0)
sinh(7.2)
sinh(7.4)
sinh(7.6)
sinh(7.8)
sinh(8.0)
sinh(-5)
sinh(0)
sinh(5)
sinh(10)
sinh(-4.0)
sinh(-3.5)
sinh(-3.0)
sinh(-2.5)
sinh(-2.0)
sinh(-1.5)
sinh(-1.0)
sinh(-0.5)
sinh(0.0)
sinh(0.5)
sinh(1.0)
sinh(1.5)
sinh(2.0)
sinh(2.5)
sinh(3.0)
sinh(3.5)
sinh(4.0)
sinh(4.5)
sinh(5.0)
sinh(5.5)
sinh(6.0)
sinh(6.5)
sinh(7.0)
sinh(7.5)
sinh(8.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
?
e0.5
e1.0
e1.5
e2.0
e2.5
e3.0
e3.5
e4.0
e4.5
e5.0
e5.5
e6.0
e6.5
e7.0
e7.5
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
e2.1
e2.2
e2.3
e2.4
e2.5
e2.6
e2.7
e2.8
e2.9
e3.0
e3.1
e3.2
e3.3
e3.4
e3.5
e3.6
e3.7
e3.8
e3.9
e4.0
e4.1
e4.2
e4.3
e4.4
e4.5
e4.6
e4.7
e4.8
e4.9
e5.0
e5.1
e5.2
e5.3
e5.4
e5.5
e5.6
e5.7
e5.8
e5.9
e6.0
e6.1
e6.2
e6.3
e6.4
e6.5
e6.6
e6.7
e6.8
e6.9
e7.0
e0
e2
e4
e6
e8
e0.0
e0.2
e0.4
e0.6
e0.8
e1.0
e1.2
e1.4
e1.6
e1.8
e2.0
e2.2
e2.4
e2.6
e2.8
e3.0
e3.2
e3.4
e3.6
e3.8
e4.0
e4.2
e4.4
e4.6
e4.8
e5.0
e5.2
e5.4
e5.6
e5.8
e6.0
e6.2
e6.4
e6.6
e6.8
e7.0
y
Cty
-50
-40
-30
-20
-10
0
10
20
30
40
50
60
70
80
90
-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
-50
0
50
100
-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
a4
a4
a4
a4
a4
a4
a4
a4 quattro
a4 quattro
a4 quattro
a4 quattro
a4 quattro
a4 quattro
a4 quattro
a4 quattro
a6 quattro
a6 quattro
a6 quattro
c1500 suburban 2wd
c1500 suburban 2wd
c1500 suburban 2wd
c1500 suburban 2wd
c1500 suburban 2wd
corvette
corvette
corvette
corvette
corvette
k1500 tahoe 4wd
k1500 tahoe 4wd
k1500 tahoe 4wd
k1500 tahoe 4wd
malibu
malibu
malibu
malibu
malibu
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
durango 4wd
durango 4wd
durango 4wd
durango 4wd
durango 4wd
durango 4wd
durango 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
expedition 2wd
expedition 2wd
expedition 2wd
explorer 4wd
explorer 4wd
explorer 4wd
explorer 4wd
explorer 4wd
explorer 4wd
f150 pickup 4wd
f150 pickup 4wd
f150 pickup 4wd
f150 pickup 4wd
f150 pickup 4wd
f150 pickup 4wd
f150 pickup 4wd
mustang
mustang
mustang
mustang
mustang
mustang
mustang
mustang
mustang
civic
civic
civic
civic
civic
civic
civic
civic
civic
sonata
sonata
sonata
sonata
sonata
sonata
sonata
tiburon
tiburon
tiburon
tiburon
tiburon
tiburon
tiburon
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
range rover
range rover
range rover
range rover
navigator 2wd
navigator 2wd
navigator 2wd
mountaineer 4wd
mountaineer 4wd
mountaineer 4wd
mountaineer 4wd
altima
altima
altima
altima
altima
altima
maxima
maxima
maxima
pathfinder 4wd
pathfinder 4wd
pathfinder 4wd
pathfinder 4wd
grand prix
grand prix
grand prix
grand prix
grand prix
forester awd
forester awd
forester awd
forester awd
forester awd
forester awd
impreza awd
impreza awd
impreza awd
impreza awd
impreza awd
impreza awd
impreza awd
impreza awd
4runner 4wd
4runner 4wd
4runner 4wd
4runner 4wd
4runner 4wd
4runner 4wd
camry
camry
camry
camry
camry
camry
camry
camry solara
camry solara
camry solara
camry solara
camry solara
camry solara
camry solara
corolla
corolla
corolla
corolla
corolla
land cruiser wagon 4wd
land cruiser wagon 4wd
toyota tacoma 4wd
toyota tacoma 4wd
toyota tacoma 4wd
toyota tacoma 4wd
toyota tacoma 4wd
toyota tacoma 4wd
toyota tacoma 4wd
gti
gti
gti
gti
gti
jetta
jetta
jetta
jetta
jetta
jetta
jetta
jetta
jetta
new beetle
new beetle
new beetle
new beetle
new beetle
new beetle
passat
passat
passat
passat
passat
passat
passat
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
?
y=x
-60
-50
-40
-30
-20
-10
0
10
20
30
40
50
60
70
80
90
100
110
-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
-50
0
50
100
-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
Hwy
using Gadfly, RDatasets
set_default_plot_size(14cm, 8cm)
plot(dataset("HistData", "ChestSizes"), x="Chest", y="Count", Geom.bar)
using Gadfly, RDatasets, DataFrames
set_default_plot_size(21cm, 8cm)
D = by(dataset("datasets","HairEyeColor"), [:Eye,:Sex], d->sum(d[:Freq]))
p1 = plot(D, color="Eye", y="x1", x="Sex", Geom.bar(position=:dodge),
Guide.ylabel("Freq"));
rename!(D, :x1 => :Frequency)
palette = ["brown","blue","tan","green"] # Is there a hazel color?
p2a = plot(D, x=:Sex, y=:Frequency, color=:Eye, Geom.bar(position=:stack),
Scale.color_discrete_manual(palette...));
p2b = 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(p1, p2a, p2b)
See Scale.color_discrete_manual
for more information.
using Gadfly, RDatasets
set_default_plot_size(14cm, 8cm)
plot(dataset("lattice", "singer"), x="VoicePart", y="Height", Geom.beeswarm)
VoicePart
Soprano 1
Soprano 2
Alto 1
Alto 2
Tenor 1
Tenor 2
Bass 1
Bass 2
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
?
35
40
45
50
55
60
65
70
75
80
85
90
95
100
105
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
40
60
80
100
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
Height
using Compose, Gadfly, RDatasets
set_default_plot_size(21cm, 8cm)
singers, salaries = dataset("lattice", "singer"), dataset("car","Salaries")
salaries.Salary /= 1000.0
salaries.Discipline = ["Discipline $(x)" for x in salaries.Discipline]
p1 = plot(singers, x=:VoicePart, y=:Height, Geom.boxplot,
Theme(default_color="MidnightBlue"))
p2 = plot(salaries, x=:Discipline, y=:Salary, color=:Rank,
Scale.x_discrete(levels=["Discipline A", "Discipline B"]),
Geom.boxplot, Theme(boxplot_spacing=0.1cx),
Guide.colorkey(title="", pos=[0.78w,-0.4h])
)
hstack(p1, p2)
Discipline
Discipline A
Discipline B
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
?
Prof
AsstProf
AssocProf
-300
-250
-200
-150
-100
-50
0
50
100
150
200
250
300
350
400
450
500
550
-250
-240
-230
-220
-210
-200
-190
-180
-170
-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
330
340
350
360
370
380
390
400
410
420
430
440
450
460
470
480
490
500
-250
0
250
500
-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
Salary
VoicePart
Soprano 1
Soprano 2
Alto 1
Alto 2
Tenor 1
Tenor 2
Bass 1
Bass 2
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
?
35
40
45
50
55
60
65
70
75
80
85
90
95
100
105
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
40
60
80
100
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
Height
using Gadfly
set_default_plot_size(14cm, 8cm)
plot(z=(x,y) -> x*exp(-(x-round(Int, x))^2-y^2),
xmin=[-8], xmax=[8], ymin=[-2], ymax=[2], Geom.contour)
xmin
-35
-30
-25
-20
-15
-10
-5
0
5
10
15
20
25
30
35
-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
-40
-20
0
20
40
-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
-5
10
-10
0
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
?
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
-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
-6
-3
0
3
6
-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
ymin
using Gadfly, RDatasets
set_default_plot_size(21cm, 16cm)
volcano = Matrix{Float64}(dataset("datasets", "volcano"))
p1 = plot(z=volcano, Geom.contour)
p2 = plot(z=volcano, Geom.contour(levels=[110.0, 150.0, 180.0, 190.0]))
p3 = plot(z=volcano, x=collect(0.0:10:860.0), y=collect(0.0:10:600.0),
Geom.contour(levels=2))
Mv = volcano[1:4:end, 1:4:end]
Dv = vcat([DataFrame(x=[1:size(Mv,1);], y=j, z=Mv[:,j]) for j in 1:size(Mv,2)]...)
p4 = plot(Dv, x=:x, y=:y, z=:z, color=:z,
Coord.cartesian(xmin=1, xmax=22, ymin=1, ymax=16),
Geom.point, Geom.contour(levels=10),
style(line_width=0.5mm, point_size=0.2mm) )
gridstack([p1 p2; p3 p4])
using Gadfly, RDatasets, Distributions
set_default_plot_size(21cm, 8cm)
p1 = plot(dataset("ggplot2", "diamonds"), x="Price", Geom.density)
p2 = plot(dataset("ggplot2", "diamonds"), x="Price", color="Cut", Geom.density)
hstack(p1,p2)
Price
-6×10⁴
-5×10⁴
-4×10⁴
-3×10⁴
-2×10⁴
-1×10⁴
0
1×10⁴
2×10⁴
3×10⁴
4×10⁴
5×10⁴
6×10⁴
7×10⁴
8×10⁴
-5.0×10⁴
-4.8×10⁴
-4.6×10⁴
-4.4×10⁴
-4.2×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⁴
-8.0×10³
-6.0×10³
-4.0×10³
-2.0×10³
0
2.0×10³
4.0×10³
6.0×10³
8.0×10³
1.0×10⁴
1.2×10⁴
1.4×10⁴
1.6×10⁴
1.8×10⁴
2.0×10⁴
2.2×10⁴
2.4×10⁴
2.6×10⁴
2.8×10⁴
3.0×10⁴
3.2×10⁴
3.4×10⁴
3.6×10⁴
3.8×10⁴
4.0×10⁴
4.2×10⁴
4.4×10⁴
4.6×10⁴
4.8×10⁴
5.0×10⁴
5.2×10⁴
5.4×10⁴
5.6×10⁴
5.8×10⁴
6.0×10⁴
6.2×10⁴
6.4×10⁴
6.6×10⁴
6.8×10⁴
7.0×10⁴
-5×10⁴
0
5×10⁴
1×10⁵
-5.0×10⁴
-4.5×10⁴
-4.0×10⁴
-3.5×10⁴
-3.0×10⁴
-2.5×10⁴
-2.0×10⁴
-1.5×10⁴
-1.0×10⁴
-5.0×10³
0
5.0×10³
1.0×10⁴
1.5×10⁴
2.0×10⁴
2.5×10⁴
3.0×10⁴
3.5×10⁴
4.0×10⁴
4.5×10⁴
5.0×10⁴
5.5×10⁴
6.0×10⁴
6.5×10⁴
7.0×10⁴
Ideal
Premium
Good
Very Good
Fair
Cut
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
?
-0.0006
-0.0005
-0.0004
-0.0003
-0.0002
-0.0001
0.0000
0.0001
0.0002
0.0003
0.0004
0.0005
0.0006
0.0007
0.0008
0.0009
0.0010
0.0011
-0.00050
-0.00048
-0.00046
-0.00044
-0.00042
-0.00040
-0.00038
-0.00036
-0.00034
-0.00032
-0.00030
-0.00028
-0.00026
-0.00024
-0.00022
-0.00020
-0.00018
-0.00016
-0.00014
-0.00012
-0.00010
-0.00008
-0.00006
-0.00004
-0.00002
0.00000
0.00002
0.00004
0.00006
0.00008
0.00010
0.00012
0.00014
0.00016
0.00018
0.00020
0.00022
0.00024
0.00026
0.00028
0.00030
0.00032
0.00034
0.00036
0.00038
0.00040
0.00042
0.00044
0.00046
0.00048
0.00050
0.00052
0.00054
0.00056
0.00058
0.00060
0.00062
0.00064
0.00066
0.00068
0.00070
0.00072
0.00074
0.00076
0.00078
0.00080
0.00082
0.00084
0.00086
0.00088
0.00090
0.00092
0.00094
0.00096
0.00098
0.00100
-0.0005
0.0000
0.0005
0.0010
-0.00050
-0.00045
-0.00040
-0.00035
-0.00030
-0.00025
-0.00020
-0.00015
-0.00010
-0.00005
0.00000
0.00005
0.00010
0.00015
0.00020
0.00025
0.00030
0.00035
0.00040
0.00045
0.00050
0.00055
0.00060
0.00065
0.00070
0.00075
0.00080
0.00085
0.00090
0.00095
0.00100
Price
-6×10⁴
-5×10⁴
-4×10⁴
-3×10⁴
-2×10⁴
-1×10⁴
0
1×10⁴
2×10⁴
3×10⁴
4×10⁴
5×10⁴
6×10⁴
7×10⁴
8×10⁴
-5.0×10⁴
-4.8×10⁴
-4.6×10⁴
-4.4×10⁴
-4.2×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⁴
-8.0×10³
-6.0×10³
-4.0×10³
-2.0×10³
0
2.0×10³
4.0×10³
6.0×10³
8.0×10³
1.0×10⁴
1.2×10⁴
1.4×10⁴
1.6×10⁴
1.8×10⁴
2.0×10⁴
2.2×10⁴
2.4×10⁴
2.6×10⁴
2.8×10⁴
3.0×10⁴
3.2×10⁴
3.4×10⁴
3.6×10⁴
3.8×10⁴
4.0×10⁴
4.2×10⁴
4.4×10⁴
4.6×10⁴
4.8×10⁴
5.0×10⁴
5.2×10⁴
5.4×10⁴
5.6×10⁴
5.8×10⁴
6.0×10⁴
6.2×10⁴
6.4×10⁴
6.6×10⁴
6.8×10⁴
7.0×10⁴
-5×10⁴
0
5×10⁴
1×10⁵
-5.0×10⁴
-4.5×10⁴
-4.0×10⁴
-3.5×10⁴
-3.0×10⁴
-2.5×10⁴
-2.0×10⁴
-1.5×10⁴
-1.0×10⁴
-5.0×10³
0
5.0×10³
1.0×10⁴
1.5×10⁴
2.0×10⁴
2.5×10⁴
3.0×10⁴
3.5×10⁴
4.0×10⁴
4.5×10⁴
5.0×10⁴
5.5×10⁴
6.0×10⁴
6.5×10⁴
7.0×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
?
-0.0005
-0.0004
-0.0003
-0.0002
-0.0001
0.0000
0.0001
0.0002
0.0003
0.0004
0.0005
0.0006
0.0007
0.0008
0.0009
-0.00040
-0.00038
-0.00036
-0.00034
-0.00032
-0.00030
-0.00028
-0.00026
-0.00024
-0.00022
-0.00020
-0.00018
-0.00016
-0.00014
-0.00012
-0.00010
-0.00008
-0.00006
-0.00004
-0.00002
0.00000
0.00002
0.00004
0.00006
0.00008
0.00010
0.00012
0.00014
0.00016
0.00018
0.00020
0.00022
0.00024
0.00026
0.00028
0.00030
0.00032
0.00034
0.00036
0.00038
0.00040
0.00042
0.00044
0.00046
0.00048
0.00050
0.00052
0.00054
0.00056
0.00058
0.00060
0.00062
0.00064
0.00066
0.00068
0.00070
0.00072
0.00074
0.00076
0.00078
0.00080
-0.0005
0.0000
0.0005
0.0010
-0.00040
-0.00035
-0.00030
-0.00025
-0.00020
-0.00015
-0.00010
-0.00005
0.00000
0.00005
0.00010
0.00015
0.00020
0.00025
0.00030
0.00035
0.00040
0.00045
0.00050
0.00055
0.00060
0.00065
0.00070
0.00075
0.00080
using Gadfly, RDatasets, Distributions
set_default_plot_size(14cm, 8cm)
dist = MixtureModel(Normal, [(0.5, 0.2), (1, 0.1)])
xs = rand(dist, 10^5)
plot(layer(x=xs, Geom.density, Theme(default_color="orange")),
layer(x=xs, Geom.density(bandwidth=0.0003), Theme(default_color="green")),
layer(x=xs, Geom.density(bandwidth=0.25), Theme(default_color="purple")),
Guide.manual_color_key("bandwidth", ["auto", "bw=0.0003", "bw=0.25"],
["orange", "green", "purple"]))
x
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
-7.0
-6.8
-6.6
-6.4
-6.2
-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
6.2
6.4
6.6
6.8
7.0
7.2
7.4
7.6
7.8
8.0
-10
-5
0
5
10
-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
auto
bw=0.0003
bw=0.25
bandwidth
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
?
-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
-2.5
-2.4
-2.3
-2.2
-2.1
-2.0
-1.9
-1.8
-1.7
-1.6
-1.5
-1.4
-1.3
-1.2
-1.1
-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
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
-2.5
0.0
2.5
5.0
-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
using Gadfly, Distributions
set_default_plot_size(14cm, 8cm)
plot(x=rand(Rayleigh(2),1000), y=rand(Rayleigh(2),1000),
Geom.density2d(levels = x->maximum(x)*0.5.^collect(1:2:8)), Geom.point,
Theme(key_position=:none),
Scale.color_continuous(colormap=x->colorant"red"))
x
-14
-12
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
16
18
20
-12.0
-11.5
-11.0
-10.5
-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
-20
-10
0
10
20
-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
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
?
-25
-20
-15
-10
-5
0
5
10
15
20
25
30
-20.0
-19.5
-19.0
-18.5
-18.0
-17.5
-17.0
-16.5
-16.0
-15.5
-15.0
-14.5
-14.0
-13.5
-13.0
-12.5
-12.0
-11.5
-11.0
-10.5
-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.5
21.0
21.5
22.0
22.5
23.0
23.5
24.0
24.5
25.0
-20
0
20
40
-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
y
using RDatasets, Gadfly
set_default_plot_size(21cm, 8cm)
D = dataset("datasets","faithful")
D[:g] = D[:Eruptions].>3.0
coord = Coord.cartesian(ymin=40, ymax=100)
pa = plot(D, coord,
x=:Eruptions, y=:Waiting, group=:g,
Geom.point, Geom.ellipse,
Theme(lowlight_color=c->"gray") )
pb = plot(D, coord, Guide.ylabel(nothing),
x=:Eruptions, y=:Waiting, color=:g,
Geom.point, Geom.ellipse(levels=[0.95, 0.99]),
Theme(key_position=:none, lowlight_color=identity, line_style=[:solid,:dot]))
pc = plot(D, coord, Guide.ylabel(nothing),
x=:Eruptions, y=:Waiting, color=:g,
Geom.point, Geom.ellipse(fill=true),
layer(Geom.ellipse(levels=[0.99]), style(line_style=[:dot])),
Theme(key_position=:none) )
hstack(pa,pb,pc)
using Gadfly, RDatasets, Distributions, Random
set_default_plot_size(21cm, 8cm)
Random.seed!(1234)
n = 10
sds = [1, 1/2, 1/4, 1/8, 1/16, 1/32]
ys = mean.(rand.(Normal.(0, sds), n))
df = DataFrame(x=1:length(sds), y=ys,
mins=ys.-(1.96*sds/sqrt(n)), maxs=ys.+(1.96*sds/sqrt(n)),
g=repeat(["a","b"], inner=3))
p1 = plot(df, x=1:length(sds), y=:y, ymin=:mins, ymax=:maxs, color=:g,
Geom.point, Geom.errorbar)
p2 = plot(df, y=1:length(sds), x=:y, xmin=:mins, xmax=:maxs, color=:g,
Geom.point, Geom.errorbar)
hstack(p1, p2)
y
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
-2.00
-1.95
-1.90
-1.85
-1.80
-1.75
-1.70
-1.65
-1.60
-1.55
-1.50
-1.45
-1.40
-1.35
-1.30
-1.25
-1.20
-1.15
-1.10
-1.05
-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
2.05
2.10
2.15
2.20
2.25
2.30
2.35
2.40
2.45
2.50
-2
0
2
4
-2.0
-1.9
-1.8
-1.7
-1.6
-1.5
-1.4
-1.3
-1.2
-1.1
-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
2.1
2.2
2.3
2.4
2.5
a
b
g
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
8
9
10
11
12
13
-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
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
-10
0
10
20
-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
y
x
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
-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
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
-10
0
10
20
-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
a
b
g
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
?
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
-2.00
-1.95
-1.90
-1.85
-1.80
-1.75
-1.70
-1.65
-1.60
-1.55
-1.50
-1.45
-1.40
-1.35
-1.30
-1.25
-1.20
-1.15
-1.10
-1.05
-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
2.05
2.10
2.15
2.20
2.25
2.30
2.35
2.40
2.45
2.50
-2
0
2
4
-2.0
-1.9
-1.8
-1.7
-1.6
-1.5
-1.4
-1.3
-1.2
-1.1
-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
2.1
2.2
2.3
2.4
2.5
y
using Compose, DataFrames, Gadfly, RDatasets, Statistics
set_default_plot_size(21cm, 8cm)
salaries = dataset("car","Salaries")
salaries.Salary /= 1000.0
salaries.Discipline = ["Discipline $(x)" for x in salaries.Discipline]
df = by(salaries, [:Rank,:Discipline], :Salary=>mean, :Salary=>std)
[df[i] = df.Salary_mean.+j*df.Salary_std for (i,j) in zip([:ymin, :ymax], [-1, 1.0])]
df[:label] = string.(round.(Int, df.Salary_mean))
p1 = plot(df, x=:Discipline, y=:Salary_mean, color=:Rank,
Scale.x_discrete(levels=["Discipline A", "Discipline B"]),
ymin=:ymin, ymax=:ymax, Geom.errorbar, Stat.dodge,
Geom.bar(position=:dodge),
Scale.color_discrete(levels=["Prof", "AssocProf", "AsstProf"]),
Guide.colorkey(title="", pos=[0.76w, -0.38h]),
Theme(bar_spacing=0mm, stroke_color=c->"black")
)
p2 = plot(df, y=:Discipline, x=:Salary_mean, color=:Rank,
Coord.cartesian(yflip=true), Scale.y_discrete,
xmin=:ymin, xmax=:ymax, Geom.errorbar, Stat.dodge(axis=:y),
Geom.bar(position=:dodge, orientation=:horizontal),
Scale.color_discrete(levels=["Prof", "AssocProf", "AsstProf"]),
Guide.yticks(orientation=:vertical), Guide.ylabel(nothing),
Theme(bar_spacing=0mm, stroke_color=c->"gray")
)
hstack(p1,p2)
Salary_mean
-250
-200
-150
-100
-50
0
50
100
150
200
250
300
350
400
450
-200
-190
-180
-170
-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
330
340
350
360
370
380
390
400
-200
0
200
400
-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
Prof
AssocProf
AsstProf
Rank
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
?
Discipline B
Discipline A
Discipline B
Discipline A
Discipline
Discipline A
Discipline B
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
?
Prof
AssocProf
AsstProf
-250
-200
-150
-100
-50
0
50
100
150
200
250
300
350
400
450
-200
-190
-180
-170
-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
330
340
350
360
370
380
390
400
-200
0
200
400
-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
Salary_mean
using Gadfly
set_default_plot_size(21cm, 8cm)
x= 1:10
s = [-1,-1,1,1,-1,-1,1,1,-1,-1]
pa = plot(x=x, y=x.^2, Geom.hair, Geom.point)
pb = plot(x=s.*(x.^2), y=x, color=string.(s),
Geom.hair(orientation=:horizontal), Geom.point, Theme(key_position=:none))
hstack(pa, pb)
x
-350
-300
-250
-200
-150
-100
-50
0
50
100
150
200
250
300
350
-300
-290
-280
-270
-260
-250
-240
-230
-220
-210
-200
-190
-180
-170
-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
-400
-200
0
200
400
-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
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
?
-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.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
0
10
20
-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
y
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.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
0
10
20
-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
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
?
-150
-100
-50
0
50
100
150
200
250
-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
-100
0
100
200
-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
y
using Gadfly, Distributions
set_default_plot_size(21cm, 8cm)
X = rand(MultivariateNormal([0.0, 0.0], [1.0 0.5; 0.5 1.0]), 10000);
p1 = plot(x=X[1,:], y=X[2,:], Geom.hexbin)
p2 = plot(x=X[1,:], y=X[2,:], Geom.hexbin(xbincount=100, ybincount=100))
hstack(p1,p2)
x
-20
-15
-10
-5
0
5
10
15
20
-15.0
-14.5
-14.0
-13.5
-13.0
-12.5
-12.0
-11.5
-11.0
-10.5
-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
-20
-10
0
10
20
-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
30
20
40
1
10
Count
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
?
-14
-12
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
-12.0
-11.5
-11.0
-10.5
-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
-20
-10
0
10
20
-12.0
-11.5
-11.0
-10.5
-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
y
x
-20
-15
-10
-5
0
5
10
15
20
-15.0
-14.5
-14.0
-13.5
-13.0
-12.5
-12.0
-11.5
-11.0
-10.5
-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
-20
-10
0
10
20
-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
15
1
10
5
Count
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
?
-14
-12
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
-12.0
-11.5
-11.0
-10.5
-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
-20
-10
0
10
20
-12.0
-11.5
-11.0
-10.5
-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
y
using Distributions, Gadfly, RDatasets
set_default_plot_size(21cm, 16cm)
D = dataset("ggplot2","diamonds")
gamma = Gamma(2, 2)
Dgamma = DataFrame(x=rand(gamma, 10^4))
p1 = plot(D, x="Price", Geom.histogram)
p2 = plot(D, x="Price", color="Cut", Geom.histogram)
p3 = plot(D, x="Price", color="Cut", Geom.histogram(bincount=30))
p4 = plot(Dgamma, Coord.cartesian(xmin=0, xmax=20),
layer(x->pdf(gamma, x), 0, 20, Geom.line, Theme(default_color="black")),
layer(x=:x, Geom.histogram(bincount=20, density=true, limits=(min=0,))),
Theme(default_color="bisque") )
gridstack([p1 p2; p3 p4])
x
-25
-20
-15
-10
-5
0
5
10
15
20
25
30
35
40
45
-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
-20
0
20
40
-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
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
?
-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.20
-0.19
-0.18
-0.17
-0.16
-0.15
-0.14
-0.13
-0.12
-0.11
-0.10
-0.09
-0.08
-0.07
-0.06
-0.05
-0.04
-0.03
-0.02
-0.01
0.00
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
0.09
0.10
0.11
0.12
0.13
0.14
0.15
0.16
0.17
0.18
0.19
0.20
0.21
0.22
0.23
0.24
0.25
0.26
0.27
0.28
0.29
0.30
0.31
0.32
0.33
0.34
0.35
0.36
0.37
0.38
0.39
0.40
0.41
-0.2
0.0
0.2
0.4
-0.20
-0.18
-0.16
-0.14
-0.12
-0.10
-0.08
-0.06
-0.04
-0.02
0.00
0.02
0.04
0.06
0.08
0.10
0.12
0.14
0.16
0.18
0.20
0.22
0.24
0.26
0.28
0.30
0.32
0.34
0.36
0.38
0.40
0.42
y
Price
-2.5×10⁴
-2.0×10⁴
-1.5×10⁴
-1.0×10⁴
-5.0×10³
0
5.0×10³
1.0×10⁴
1.5×10⁴
2.0×10⁴
2.5×10⁴
3.0×10⁴
3.5×10⁴
4.0×10⁴
4.5×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⁴
-9.0×10³
-8.0×10³
-7.0×10³
-6.0×10³
-5.0×10³
-4.0×10³
-3.0×10³
-2.0×10³
-1.0×10³
0
1.0×10³
2.0×10³
3.0×10³
4.0×10³
5.0×10³
6.0×10³
7.0×10³
8.0×10³
9.0×10³
1.0×10⁴
1.1×10⁴
1.2×10⁴
1.3×10⁴
1.4×10⁴
1.5×10⁴
1.6×10⁴
1.7×10⁴
1.8×10⁴
1.9×10⁴
2.0×10⁴
2.1×10⁴
2.2×10⁴
2.3×10⁴
2.4×10⁴
2.5×10⁴
2.6×10⁴
2.7×10⁴
2.8×10⁴
2.9×10⁴
3.0×10⁴
3.1×10⁴
3.2×10⁴
3.3×10⁴
3.4×10⁴
3.5×10⁴
3.6×10⁴
3.7×10⁴
3.8×10⁴
3.9×10⁴
4.0×10⁴
-2×10⁴
0
2×10⁴
4×10⁴
-2.0×10⁴
-1.8×10⁴
-1.6×10⁴
-1.4×10⁴
-1.2×10⁴
-1.0×10⁴
-8.0×10³
-6.0×10³
-4.0×10³
-2.0×10³
0
2.0×10³
4.0×10³
6.0×10³
8.0×10³
1.0×10⁴
1.2×10⁴
1.4×10⁴
1.6×10⁴
1.8×10⁴
2.0×10⁴
2.2×10⁴
2.4×10⁴
2.6×10⁴
2.8×10⁴
3.0×10⁴
3.2×10⁴
3.4×10⁴
3.6×10⁴
3.8×10⁴
4.0×10⁴
Ideal
Premium
Good
Very Good
Fair
Cut
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
?
-2.0×10⁴
-1.5×10⁴
-1.0×10⁴
-5.0×10³
0
5.0×10³
1.0×10⁴
1.5×10⁴
2.0×10⁴
2.5×10⁴
3.0×10⁴
3.5×10⁴
-1.50×10⁴
-1.45×10⁴
-1.40×10⁴
-1.35×10⁴
-1.30×10⁴
-1.25×10⁴
-1.20×10⁴
-1.15×10⁴
-1.10×10⁴
-1.05×10⁴
-1.00×10⁴
-9.50×10³
-9.00×10³
-8.50×10³
-8.00×10³
-7.50×10³
-7.00×10³
-6.50×10³
-6.00×10³
-5.50×10³
-5.00×10³
-4.50×10³
-4.00×10³
-3.50×10³
-3.00×10³
-2.50×10³
-2.00×10³
-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³
3.00×10³
3.50×10³
4.00×10³
4.50×10³
5.00×10³
5.50×10³
6.00×10³
6.50×10³
7.00×10³
7.50×10³
8.00×10³
8.50×10³
9.00×10³
9.50×10³
1.00×10⁴
1.05×10⁴
1.10×10⁴
1.15×10⁴
1.20×10⁴
1.25×10⁴
1.30×10⁴
1.35×10⁴
1.40×10⁴
1.45×10⁴
1.50×10⁴
1.55×10⁴
1.60×10⁴
1.65×10⁴
1.70×10⁴
1.75×10⁴
1.80×10⁴
1.85×10⁴
1.90×10⁴
1.95×10⁴
2.00×10⁴
2.05×10⁴
2.10×10⁴
2.15×10⁴
2.20×10⁴
2.25×10⁴
2.30×10⁴
2.35×10⁴
2.40×10⁴
2.45×10⁴
2.50×10⁴
2.55×10⁴
2.60×10⁴
2.65×10⁴
2.70×10⁴
2.75×10⁴
2.80×10⁴
2.85×10⁴
2.90×10⁴
2.95×10⁴
3.00×10⁴
-2×10⁴
0
2×10⁴
4×10⁴
-1.5×10⁴
-1.4×10⁴
-1.3×10⁴
-1.2×10⁴
-1.1×10⁴
-1.0×10⁴
-9.0×10³
-8.0×10³
-7.0×10³
-6.0×10³
-5.0×10³
-4.0×10³
-3.0×10³
-2.0×10³
-1.0×10³
0
1.0×10³
2.0×10³
3.0×10³
4.0×10³
5.0×10³
6.0×10³
7.0×10³
8.0×10³
9.0×10³
1.0×10⁴
1.1×10⁴
1.2×10⁴
1.3×10⁴
1.4×10⁴
1.5×10⁴
1.6×10⁴
1.7×10⁴
1.8×10⁴
1.9×10⁴
2.0×10⁴
2.1×10⁴
2.2×10⁴
2.3×10⁴
2.4×10⁴
2.5×10⁴
2.6×10⁴
2.7×10⁴
2.8×10⁴
2.9×10⁴
3.0×10⁴
Price
-2.5×10⁴
-2.0×10⁴
-1.5×10⁴
-1.0×10⁴
-5.0×10³
0
5.0×10³
1.0×10⁴
1.5×10⁴
2.0×10⁴
2.5×10⁴
3.0×10⁴
3.5×10⁴
4.0×10⁴
4.5×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⁴
-9.0×10³
-8.0×10³
-7.0×10³
-6.0×10³
-5.0×10³
-4.0×10³
-3.0×10³
-2.0×10³
-1.0×10³
0
1.0×10³
2.0×10³
3.0×10³
4.0×10³
5.0×10³
6.0×10³
7.0×10³
8.0×10³
9.0×10³
1.0×10⁴
1.1×10⁴
1.2×10⁴
1.3×10⁴
1.4×10⁴
1.5×10⁴
1.6×10⁴
1.7×10⁴
1.8×10⁴
1.9×10⁴
2.0×10⁴
2.1×10⁴
2.2×10⁴
2.3×10⁴
2.4×10⁴
2.5×10⁴
2.6×10⁴
2.7×10⁴
2.8×10⁴
2.9×10⁴
3.0×10⁴
3.1×10⁴
3.2×10⁴
3.3×10⁴
3.4×10⁴
3.5×10⁴
3.6×10⁴
3.7×10⁴
3.8×10⁴
3.9×10⁴
4.0×10⁴
-2×10⁴
0
2×10⁴
4×10⁴
-2.0×10⁴
-1.8×10⁴
-1.6×10⁴
-1.4×10⁴
-1.2×10⁴
-1.0×10⁴
-8.0×10³
-6.0×10³
-4.0×10³
-2.0×10³
0
2.0×10³
4.0×10³
6.0×10³
8.0×10³
1.0×10⁴
1.2×10⁴
1.4×10⁴
1.6×10⁴
1.8×10⁴
2.0×10⁴
2.2×10⁴
2.4×10⁴
2.6×10⁴
2.8×10⁴
3.0×10⁴
3.2×10⁴
3.4×10⁴
3.6×10⁴
3.8×10⁴
4.0×10⁴
Ideal
Premium
Good
Very Good
Fair
Cut
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
?
-5×10³
-4×10³
-3×10³
-2×10³
-1×10³
0
1×10³
2×10³
3×10³
4×10³
5×10³
6×10³
7×10³
8×10³
9×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³
-8.0×10²
-6.0×10²
-4.0×10²
-2.0×10²
0
2.0×10²
4.0×10²
6.0×10²
8.0×10²
1.0×10³
1.2×10³
1.4×10³
1.6×10³
1.8×10³
2.0×10³
2.2×10³
2.4×10³
2.6×10³
2.8×10³
3.0×10³
3.2×10³
3.4×10³
3.6×10³
3.8×10³
4.0×10³
4.2×10³
4.4×10³
4.6×10³
4.8×10³
5.0×10³
5.2×10³
5.4×10³
5.6×10³
5.8×10³
6.0×10³
6.2×10³
6.4×10³
6.6×10³
6.8×10³
7.0×10³
7.2×10³
7.4×10³
7.6×10³
7.8×10³
8.0×10³
-5×10³
0
5×10³
1×10⁴
-4.0×10³
-3.5×10³
-3.0×10³
-2.5×10³
-2.0×10³
-1.5×10³
-1.0×10³
-5.0×10²
0
5.0×10²
1.0×10³
1.5×10³
2.0×10³
2.5×10³
3.0×10³
3.5×10³
4.0×10³
4.5×10³
5.0×10³
5.5×10³
6.0×10³
6.5×10³
7.0×10³
7.5×10³
8.0×10³
Price
-2.5×10⁴
-2.0×10⁴
-1.5×10⁴
-1.0×10⁴
-5.0×10³
0
5.0×10³
1.0×10⁴
1.5×10⁴
2.0×10⁴
2.5×10⁴
3.0×10⁴
3.5×10⁴
4.0×10⁴
4.5×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⁴
-9.0×10³
-8.0×10³
-7.0×10³
-6.0×10³
-5.0×10³
-4.0×10³
-3.0×10³
-2.0×10³
-1.0×10³
0
1.0×10³
2.0×10³
3.0×10³
4.0×10³
5.0×10³
6.0×10³
7.0×10³
8.0×10³
9.0×10³
1.0×10⁴
1.1×10⁴
1.2×10⁴
1.3×10⁴
1.4×10⁴
1.5×10⁴
1.6×10⁴
1.7×10⁴
1.8×10⁴
1.9×10⁴
2.0×10⁴
2.1×10⁴
2.2×10⁴
2.3×10⁴
2.4×10⁴
2.5×10⁴
2.6×10⁴
2.7×10⁴
2.8×10⁴
2.9×10⁴
3.0×10⁴
3.1×10⁴
3.2×10⁴
3.3×10⁴
3.4×10⁴
3.5×10⁴
3.6×10⁴
3.7×10⁴
3.8×10⁴
3.9×10⁴
4.0×10⁴
-2×10⁴
0
2×10⁴
4×10⁴
-2.0×10⁴
-1.8×10⁴
-1.6×10⁴
-1.4×10⁴
-1.2×10⁴
-1.0×10⁴
-8.0×10³
-6.0×10³
-4.0×10³
-2.0×10³
0
2.0×10³
4.0×10³
6.0×10³
8.0×10³
1.0×10⁴
1.2×10⁴
1.4×10⁴
1.6×10⁴
1.8×10⁴
2.0×10⁴
2.2×10⁴
2.4×10⁴
2.6×10⁴
2.8×10⁴
3.0×10⁴
3.2×10⁴
3.4×10⁴
3.6×10⁴
3.8×10⁴
4.0×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
?
-5×10³
-4×10³
-3×10³
-2×10³
-1×10³
0
1×10³
2×10³
3×10³
4×10³
5×10³
6×10³
7×10³
8×10³
9×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³
-8.0×10²
-6.0×10²
-4.0×10²
-2.0×10²
0
2.0×10²
4.0×10²
6.0×10²
8.0×10²
1.0×10³
1.2×10³
1.4×10³
1.6×10³
1.8×10³
2.0×10³
2.2×10³
2.4×10³
2.6×10³
2.8×10³
3.0×10³
3.2×10³
3.4×10³
3.6×10³
3.8×10³
4.0×10³
4.2×10³
4.4×10³
4.6×10³
4.8×10³
5.0×10³
5.2×10³
5.4×10³
5.6×10³
5.8×10³
6.0×10³
6.2×10³
6.4×10³
6.6×10³
6.8×10³
7.0×10³
7.2×10³
7.4×10³
7.6×10³
7.8×10³
8.0×10³
-5×10³
0
5×10³
1×10⁴
-4.0×10³
-3.5×10³
-3.0×10³
-2.5×10³
-2.0×10³
-1.5×10³
-1.0×10³
-5.0×10²
0
5.0×10²
1.0×10³
1.5×10³
2.0×10³
2.5×10³
3.0×10³
3.5×10³
4.0×10³
4.5×10³
5.0×10³
5.5×10³
6.0×10³
6.5×10³
7.0×10³
7.5×10³
8.0×10³
using Gadfly, RDatasets
set_default_plot_size(21cm, 8cm)
p1 = plot(dataset("car", "Womenlf"), x="HIncome", y="Region", Geom.histogram2d)
p2 = plot(dataset("car", "UN"), x="GDP", y="InfantMortality",
Scale.x_log10, Scale.y_log10, Geom.histogram2d)
p3 = plot(dataset("car", "UN"), x="GDP", y="InfantMortality",
Scale.x_log10, Scale.y_log10, Geom.histogram2d(xbincount=30, ybincount=30))
hstack(p1,p2,p3)
using Gadfly, RDatasets
set_default_plot_size(21cm, 8cm)
p1 = plot(dataset("datasets", "iris"), x="SepalLength", y="SepalWidth",
xintercept=[5.0, 7.0], Geom.point, Geom.vline(style=[:solid,[1mm,1mm]]))
p2 = plot(dataset("datasets", "iris"), x="SepalLength", y="SepalWidth",
yintercept=[2.5, 4.0], Geom.point,
Geom.hline(color=["orange","red"], size=[2mm,3mm]))
hstack(p1,p2)
SepalLength
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
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
0
5
10
15
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.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
9.5
10.0
10.5
11.0
11.5
12.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.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.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
-2.5
0.0
2.5
5.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
SepalWidth
using Gadfly, RDatasets
set_default_plot_size(14cm, 8cm)
plot(dataset("ggplot2", "mpg"), x="Cty", y="Hwy", label="Model",
Geom.point, Geom.label)
Cty
-50
-40
-30
-20
-10
0
10
20
30
40
50
60
70
80
90
-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
-50
0
50
100
-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
a4
a4
a4
a4
a4
a4
a4
a4 quattro
a4 quattro
a4 quattro
a4 quattro
a4 quattro
a4 quattro
a4 quattro
a4 quattro
a6 quattro
a6 quattro
a6 quattro
c1500 suburban 2wd
c1500 suburban 2wd
c1500 suburban 2wd
c1500 suburban 2wd
c1500 suburban 2wd
corvette
corvette
corvette
corvette
corvette
k1500 tahoe 4wd
k1500 tahoe 4wd
k1500 tahoe 4wd
k1500 tahoe 4wd
malibu
malibu
malibu
malibu
malibu
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
durango 4wd
durango 4wd
durango 4wd
durango 4wd
durango 4wd
durango 4wd
durango 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
expedition 2wd
expedition 2wd
expedition 2wd
explorer 4wd
explorer 4wd
explorer 4wd
explorer 4wd
explorer 4wd
explorer 4wd
f150 pickup 4wd
f150 pickup 4wd
f150 pickup 4wd
f150 pickup 4wd
f150 pickup 4wd
f150 pickup 4wd
f150 pickup 4wd
mustang
mustang
mustang
mustang
mustang
mustang
mustang
mustang
mustang
civic
civic
civic
civic
civic
civic
civic
civic
civic
sonata
sonata
sonata
sonata
sonata
sonata
sonata
tiburon
tiburon
tiburon
tiburon
tiburon
tiburon
tiburon
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
range rover
range rover
range rover
range rover
navigator 2wd
navigator 2wd
navigator 2wd
mountaineer 4wd
mountaineer 4wd
mountaineer 4wd
mountaineer 4wd
altima
altima
altima
altima
altima
altima
maxima
maxima
maxima
pathfinder 4wd
pathfinder 4wd
pathfinder 4wd
pathfinder 4wd
grand prix
grand prix
grand prix
grand prix
grand prix
forester awd
forester awd
forester awd
forester awd
forester awd
forester awd
impreza awd
impreza awd
impreza awd
impreza awd
impreza awd
impreza awd
impreza awd
impreza awd
4runner 4wd
4runner 4wd
4runner 4wd
4runner 4wd
4runner 4wd
4runner 4wd
camry
camry
camry
camry
camry
camry
camry
camry solara
camry solara
camry solara
camry solara
camry solara
camry solara
camry solara
corolla
corolla
corolla
corolla
corolla
land cruiser wagon 4wd
land cruiser wagon 4wd
toyota tacoma 4wd
toyota tacoma 4wd
toyota tacoma 4wd
toyota tacoma 4wd
toyota tacoma 4wd
toyota tacoma 4wd
toyota tacoma 4wd
gti
gti
gti
gti
gti
jetta
jetta
jetta
jetta
jetta
jetta
jetta
jetta
jetta
new beetle
new beetle
new beetle
new beetle
new beetle
new beetle
passat
passat
passat
passat
passat
passat
passat
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
-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
-50
0
50
100
-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
Hwy
using Gadfly, RDatasets
set_default_plot_size(21cm, 8cm)
p1 = plot(dataset("MASS", "mammals"), x="Body", y="Brain", label=1,
Scale.x_log10, Scale.y_log10, Geom.point, Geom.label)
p2 = plot(dataset("MASS", "mammals"), x="Body", y="Brain", label=1,
Scale.x_log10, Scale.y_log10, Geom.label(position=:centered))
hstack(p1,p2)
using Gadfly, RDatasets
set_default_plot_size(21cm, 8cm)
p1 = plot(dataset("lattice", "melanoma"), x="Year", y="Incidence", Geom.line)
p2 = plot(dataset("Zelig", "approval"), x="Month", y="Approve", color="Year",
Geom.line)
hstack(p1,p2)
using Gadfly, Random
set_default_plot_size(21cm, 8cm)
n = 500
Random.seed!(1234)
xjumps = rand(n).-.5
yjumps = rand(n).-.5
p1 = plot(x=cumsum(xjumps),y=cumsum(yjumps),Geom.path)
t = 0:0.2:8pi
p2 = plot(x=t.*cos.(t), y=t.*sin.(t), Geom.path)
hstack(p1,p2)
x
-100
-90
-80
-70
-60
-50
-40
-30
-20
-10
0
10
20
30
40
50
60
70
80
90
100
-90
-88
-86
-84
-82
-80
-78
-76
-74
-72
-70
-68
-66
-64
-62
-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
-100
-50
0
50
100
-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
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
?
-100
-90
-80
-70
-60
-50
-40
-30
-20
-10
0
10
20
30
40
50
60
70
80
90
100
-90
-88
-86
-84
-82
-80
-78
-76
-74
-72
-70
-68
-66
-64
-62
-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
-100
-50
0
50
100
-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
y
x
-40
-35
-30
-25
-20
-15
-10
-5
0
5
10
15
20
25
30
-35
-34
-33
-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
-40
-20
0
20
40
-35
-30
-25
-20
-15
-10
-5
0
5
10
15
20
25
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
?
-25
-20
-15
-10
-5
0
5
10
15
20
25
30
-20.0
-19.5
-19.0
-18.5
-18.0
-17.5
-17.0
-16.5
-16.0
-15.5
-15.0
-14.5
-14.0
-13.5
-13.0
-12.5
-12.0
-11.5
-11.0
-10.5
-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.5
21.0
21.5
22.0
22.5
23.0
23.5
24.0
24.5
25.0
-20
0
20
40
-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
y
using Gadfly, RDatasets
set_default_plot_size(21cm, 12cm)
D = dataset("datasets", "iris")
p1 = plot(D, x="SepalLength", y="SepalWidth", Geom.point);
p2 = plot(D, x="SepalLength", y="SepalWidth", color="PetalLength", Geom.point);
p3 = plot(D, x="SepalLength", y="SepalWidth", color="Species", Geom.point);
p4 = plot(D, x="SepalLength", y="SepalWidth", color="Species", shape="Species",
Geom.point);
gridstack([p1 p2; p3 p4])
SepalLength
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
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
0
5
10
15
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
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.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.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.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
-2.5
0.0
2.5
5.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
SepalWidth
using Gadfly, RDatasets
set_default_plot_size(14cm, 8cm)
plot(dataset("lattice", "singer"), x="VoicePart", y="Height", Geom.point)
VoicePart
Soprano 1
Soprano 2
Alto 1
Alto 2
Tenor 1
Tenor 2
Bass 1
Bass 2
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
?
35
40
45
50
55
60
65
70
75
80
85
90
95
100
105
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
40
60
80
100
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
Height
using Gadfly, Distributions
set_default_plot_size(14cm, 8cm)
rdata = rand(MvNormal([0,0.],[1 0;0 1.]),100)
bdata = rand(MvNormal([1,0.],[1 0;0 1.]),100)
plot(layer(x=rdata[1,:], y=rdata[2,:], color=[colorant"red"], Geom.point),
layer(x=bdata[1,:], y=bdata[2,:], color=[colorant"blue"], Geom.point))
x
-14
-12
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
-12.0
-11.5
-11.0
-10.5
-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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using Gadfly
set_default_plot_size(14cm, 8cm)
plot(x=[0, 1, 1, 2, 2, 3, 3, 2, 2, 1, 1, 0, 4, 5, 5, 4],
y=[0, 0, 1, 1, 0, 0, 3, 3, 2, 2, 3, 3, 0, 0, 3, 3],
group=["H", "H", "H", "H", "H", "H", "H", "H",
"H", "H", "H", "H", "I", "I", "I", "I"],
Geom.polygon(preserve_order=true, fill=true))
x
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
-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
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
-5
0
5
10
-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
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
?
-4
-3
-2
-1
0
1
2
3
4
5
6
7
-3.0
-2.9
-2.8
-2.7
-2.6
-2.5
-2.4
-2.3
-2.2
-2.1
-2.0
-1.9
-1.8
-1.7
-1.6
-1.5
-1.4
-1.3
-1.2
-1.1
-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
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
-3
0
3
6
-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
using Gadfly, Colors, DataFrames, RDatasets
set_default_plot_size(21cm, 8cm)
theme1 = Theme(default_color=RGBA(0, 0.75, 1.0, 0.5))
D = DataFrame(x=[0.5,1], y=[0.5,1], x1=[0,0.5], y1=[0,0.5], x2=[1,1.5], y2=[1,1.5])
pa = plot(D, x=:x, y=:y, Geom.rectbin, theme1)
pb = plot(D, xmin=:x1, ymin=:y1, xmax=:x2, ymax=:y2, Geom.rect, theme1)
hstack(pa, pb)
x1
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
-1.50
-1.45
-1.40
-1.35
-1.30
-1.25
-1.20
-1.15
-1.10
-1.05
-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
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
-2
0
2
4
-1.5
-1.4
-1.3
-1.2
-1.1
-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
2.1
2.2
2.3
2.4
2.5
2.6
2.7
2.8
2.9
3.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
?
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
-1.50
-1.45
-1.40
-1.35
-1.30
-1.25
-1.20
-1.15
-1.10
-1.05
-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
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
-2
0
2
4
-1.5
-1.4
-1.3
-1.2
-1.1
-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
2.1
2.2
2.3
2.4
2.5
2.6
2.7
2.8
2.9
3.0
y1
x
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
-1.50
-1.45
-1.40
-1.35
-1.30
-1.25
-1.20
-1.15
-1.10
-1.05
-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
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
-2
0
2
4
-1.5
-1.4
-1.3
-1.2
-1.1
-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
2.1
2.2
2.3
2.4
2.5
2.6
2.7
2.8
2.9
3.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
?
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
-1.50
-1.45
-1.40
-1.35
-1.30
-1.25
-1.20
-1.15
-1.10
-1.05
-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
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
-2
0
2
4
-1.5
-1.4
-1.3
-1.2
-1.1
-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
2.1
2.2
2.3
2.4
2.5
2.6
2.7
2.8
2.9
3.0
y
using Gadfly, DataFrames, RDatasets
set_default_plot_size(14cm, 8cm)
plot(dataset("Zelig", "macro"), x="Year", y="Country", color="GDP", Geom.rectbin)
Year
1910
1920
1930
1940
1950
1960
1970
1980
1990
2000
2010
2020
2030
2040
2050
1920
1922
1924
1926
1928
1930
1932
1934
1936
1938
1940
1942
1944
1946
1948
1950
1952
1954
1956
1958
1960
1962
1964
1966
1968
1970
1972
1974
1976
1978
1980
1982
1984
1986
1988
1990
1992
1994
1996
1998
2000
2002
2004
2006
2008
2010
2012
2014
2016
2018
2020
2022
2024
2026
2028
2030
2032
2034
2036
2038
2040
1900
1950
2000
2050
1920
1925
1930
1935
1940
1945
1950
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000
2005
2010
2015
2020
2025
2030
2035
2040
0
15
-5
5
10
GDP
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
?
United States
Canada
United Kingdom
Netherlands
Belgium
France
West Germany
Austria
Italy
Finland
Sweden
Norway
Denmark
Japan
Country
using Gadfly, DataFrames, Distributions
set_default_plot_size(21cm, 8cm)
X = [cos.(0:0.1:20) sin.(0:0.1:20)]
x = -4:0.1:4
Da = [DataFrame(x=0:0.1:20, y=X[:,j], ymin=X[:,j].-0.5, ymax=X[:,j].+0.5, f="$f") for (j,f) in enumerate(["cos","sin"])]
Db = [DataFrame(x=x, ymax=pdf.(Normal(μ),x), ymin=0.0, u="μ=$μ") for μ in [-1,1] ]
# In the line below, 0.6 is the color opacity
p1 = plot(vcat(Da...), x=:x, y=:y, ymin=:ymin, ymax=:ymax, color=:f,
Geom.line, Geom.ribbon, Theme(alphas=[0.6])
)
p2 = plot(vcat(Db...), x = :x, y=:ymax, ymin = :ymin, ymax = :ymax,
color = :u, alpha=:u, Theme(alphas=[0.8,0.2]),
Geom.line, Geom.ribbon, Guide.ylabel("Density"),
Guide.colorkey(title="", pos=[2.5,0.6]), Guide.title("Parametric PDF")
)
hstack(p1,p2)
x
-14
-12
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
-12.0
-11.5
-11.0
-10.5
-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
-20
-10
0
10
20
-12.0
-11.5
-11.0
-10.5
-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
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
μ=1
-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
-0.40
-0.38
-0.36
-0.34
-0.32
-0.30
-0.28
-0.26
-0.24
-0.22
-0.20
-0.18
-0.16
-0.14
-0.12
-0.10
-0.08
-0.06
-0.04
-0.02
0.00
0.02
0.04
0.06
0.08
0.10
0.12
0.14
0.16
0.18
0.20
0.22
0.24
0.26
0.28
0.30
0.32
0.34
0.36
0.38
0.40
0.42
0.44
0.46
0.48
0.50
0.52
0.54
0.56
0.58
0.60
0.62
0.64
0.66
0.68
0.70
0.72
0.74
0.76
0.78
0.80
0.82
-0.5
0.0
0.5
1.0
-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
Density
Parametric PDF
x
-25
-20
-15
-10
-5
0
5
10
15
20
25
30
35
40
45
-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
-20
0
20
40
-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
cos
sin
f
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.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
-6
-3
0
3
6
-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
y
using Gadfly, RDatasets
set_default_plot_size(21cm, 8cm)
x_data = 0.0:0.1:2.0
y_data = x_data.^2 + rand(length(x_data))
p1 = plot(x=x_data, y=y_data, Geom.point, Geom.smooth(method=:loess,smoothing=0.9))
p2 = plot(x=x_data, y=y_data, Geom.point, Geom.smooth(method=:loess,smoothing=0.2))
hstack(p1,p2)
x
-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
-2.0
-1.9
-1.8
-1.7
-1.6
-1.5
-1.4
-1.3
-1.2
-1.1
-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
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
-2
0
2
4
-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
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
?
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
-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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.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
-5
0
5
10
-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
y
using Gadfly, Random
set_default_plot_size(14cm, 8cm)
Random.seed!(1234)
plot(x=rand(25), y=rand(25), Geom.step)
x
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
-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
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
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.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
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
y
using Gadfly, RDatasets
set_default_plot_size(21cm, 8cm)
plot(dataset("datasets", "OrchardSprays"),
xgroup="Treatment", x="ColPos", y="RowPos", color="Decrease",
Geom.subplot_grid(Geom.point))
ColPos by Treatment
150
1
100
50
Decrease
A
C
F
G
H
B
E
D
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
16
18
-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
-10
0
10
20
-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
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
16
18
-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.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.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
-10
-8
-6
-4
-2
0
2
4
6
8
10
12
14
16
18
-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
-10
0
10
20
-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
RowPos
using Gadfly, RDatasets
set_default_plot_size(14cm, 25cm)
plot(dataset("vcd", "Suicide"), xgroup="Sex", ygroup="Method", x="Age", y="Freq",
Geom.subplot_grid(Geom.bar))
Age by Sex
female
male
-150
-100
-50
0
50
100
150
200
250
-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
-100
0
100
200
-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
-150
-100
-50
0
50
100
150
200
250
-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
-100
0
100
200
-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
-2000
-1500
-1000
-500
0
500
1000
1500
2000
2500
3000
3500
-1500
-1450
-1400
-1350
-1300
-1250
-1200
-1150
-1100
-1050
-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
2050
2100
2150
2200
2250
2300
2350
2400
2450
2500
2550
2600
2650
2700
2750
2800
2850
2900
2950
3000
-2000
0
2000
4000
-1500
-1400
-1300
-1200
-1100
-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
2100
2200
2300
2400
2500
2600
2700
2800
2900
3000
other
-2000
-1500
-1000
-500
0
500
1000
1500
2000
2500
3000
3500
-1500
-1450
-1400
-1350
-1300
-1250
-1200
-1150
-1100
-1050
-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
2050
2100
2150
2200
2250
2300
2350
2400
2450
2500
2550
2600
2650
2700
2750
2800
2850
2900
2950
3000
-2000
0
2000
4000
-1500
-1400
-1300
-1200
-1100
-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
2100
2200
2300
2400
2500
2600
2700
2800
2900
3000
jump
-2000
-1500
-1000
-500
0
500
1000
1500
2000
2500
3000
3500
-1500
-1450
-1400
-1350
-1300
-1250
-1200
-1150
-1100
-1050
-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
2050
2100
2150
2200
2250
2300
2350
2400
2450
2500
2550
2600
2650
2700
2750
2800
2850
2900
2950
3000
-2000
0
2000
4000
-1500
-1400
-1300
-1200
-1100
-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
2100
2200
2300
2400
2500
2600
2700
2800
2900
3000
knife
-2000
-1500
-1000
-500
0
500
1000
1500
2000
2500
3000
3500
-1500
-1450
-1400
-1350
-1300
-1250
-1200
-1150
-1100
-1050
-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
2050
2100
2150
2200
2250
2300
2350
2400
2450
2500
2550
2600
2650
2700
2750
2800
2850
2900
2950
3000
-2000
0
2000
4000
-1500
-1400
-1300
-1200
-1100
-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
2100
2200
2300
2400
2500
2600
2700
2800
2900
3000
gun
-2000
-1500
-1000
-500
0
500
1000
1500
2000
2500
3000
3500
-1500
-1450
-1400
-1350
-1300
-1250
-1200
-1150
-1100
-1050
-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
2050
2100
2150
2200
2250
2300
2350
2400
2450
2500
2550
2600
2650
2700
2750
2800
2850
2900
2950
3000
-2000
0
2000
4000
-1500
-1400
-1300
-1200
-1100
-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
2100
2200
2300
2400
2500
2600
2700
2800
2900
3000
drown
-2000
-1500
-1000
-500
0
500
1000
1500
2000
2500
3000
3500
-1500
-1450
-1400
-1350
-1300
-1250
-1200
-1150
-1100
-1050
-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
2050
2100
2150
2200
2250
2300
2350
2400
2450
2500
2550
2600
2650
2700
2750
2800
2850
2900
2950
3000
-2000
0
2000
4000
-1500
-1400
-1300
-1200
-1100
-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
2100
2200
2300
2400
2500
2600
2700
2800
2900
3000
hang
-2000
-1500
-1000
-500
0
500
1000
1500
2000
2500
3000
3500
-1500
-1450
-1400
-1350
-1300
-1250
-1200
-1150
-1100
-1050
-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
2050
2100
2150
2200
2250
2300
2350
2400
2450
2500
2550
2600
2650
2700
2750
2800
2850
2900
2950
3000
-2000
0
2000
4000
-1500
-1400
-1300
-1200
-1100
-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
2100
2200
2300
2400
2500
2600
2700
2800
2900
3000
toxicgas
-2000
-1500
-1000
-500
0
500
1000
1500
2000
2500
3000
3500
-1500
-1450
-1400
-1350
-1300
-1250
-1200
-1150
-1100
-1050
-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
2050
2100
2150
2200
2250
2300
2350
2400
2450
2500
2550
2600
2650
2700
2750
2800
2850
2900
2950
3000
-2000
0
2000
4000
-1500
-1400
-1300
-1200
-1100
-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
2100
2200
2300
2400
2500
2600
2700
2800
2900
3000
cookgas
-2000
-1500
-1000
-500
0
500
1000
1500
2000
2500
3000
3500
-1500
-1450
-1400
-1350
-1300
-1250
-1200
-1150
-1100
-1050
-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
2050
2100
2150
2200
2250
2300
2350
2400
2450
2500
2550
2600
2650
2700
2750
2800
2850
2900
2950
3000
-2000
0
2000
4000
-1500
-1400
-1300
-1200
-1100
-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
2100
2200
2300
2400
2500
2600
2700
2800
2900
3000
poison
Freq by Method
using Gadfly, RDatasets, DataFrames
set_default_plot_size(14cm, 8cm)
iris = dataset("datasets", "iris")
sp = unique(iris[:Species])
Dhl = DataFrame(yint=[3.0, 4.0, 2.5, 3.5, 2.5, 4.0], Species=repeat(sp, inner=[2]) )
# Try this one too:
# Dhl = DataFrame(yint=[3.0, 4.0, 2.5, 3.5], Species=repeat(sp[1:2], inner=[2]) )
plot(iris, xgroup=:Species, x=:SepalLength, y=:SepalWidth,
Geom.subplot_grid(layer(Geom.point),
layer(Dhl, xgroup=:Species, yintercept=:yint,
Geom.hline(color="red", style=:dot))))
SepalLength by Species
virginica
versicolor
setosa
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
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
0
5
10
15
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
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
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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.8
5.0
5.2
5.4
5.6
5.8
6.0
6.2
6.4
6.6
6.8
7.0
SepalWidth
using Gadfly, RDatasets, DataFrames
set_default_plot_size(14cm, 8cm)
iris = dataset("datasets", "iris")
sp = unique(iris[:Species])
Dhl = DataFrame(yint=[3.0, 4.0, 2.5, 3.5, 2.5, 4.0], Species=repeat(sp, inner=[2]) )
plot(iris, xgroup=:Species,
Geom.subplot_grid(layer(x=:SepalLength, y=:SepalWidth, Geom.point),
layer(Dhl, xgroup=:Species, yintercept=:yint,
Geom.hline(color="red", style=:dot))),
Guide.xlabel("Xlabel"), Guide.ylabel("Ylabel"))
Xlabel
virginica
versicolor
setosa
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
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
0
5
10
15
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
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
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
0
5
10
15
0.0
0.5
1.0
1.5
2.0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.0
Ylabel
using Gadfly, RDatasets, DataFrames
set_default_plot_size(14cm, 12cm)
widedf = DataFrame(x = 1:10, var1 = 1:10, var2 = (1:10).^2)
longdf = stack(widedf, [:var1, :var2])
p1 = plot(longdf, ygroup="variable", x="x", y="value", Geom.subplot_grid(Geom.point))
p2 = plot(longdf, ygroup="variable", x="x", y="value", Geom.subplot_grid(Geom.point,
free_y_axis=true))
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.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
0
10
20
-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
-150
-100
-50
0
50
100
150
200
250
-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
-100
0
100
200
-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
var2
-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.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
0
10
20
-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
var1
value by variable
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.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
0
10
20
-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
-150
-100
-50
0
50
100
150
200
250
-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
-100
0
100
200
-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
var2
-150
-100
-50
0
50
100
150
200
250
-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
-100
0
100
200
-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
var1
value by variable
using Gadfly, RDatasets
set_default_plot_size(14cm, 14cm)
seals = RDatasets.dataset("ggplot2","seals")
seals[:Latb] = seals[:Lat] + seals[:DeltaLat]
seals[:Longb] = seals[:Long] + seals[:DeltaLong]
seals[:Angle] = atan.(seals[:DeltaLat], seals[:DeltaLong])
coord = Coord.cartesian(xmin=-175.0, xmax=-119, ymin=29, ymax=50)
# Geom.vector also needs scales for both axes:
xsc = Scale.x_continuous(minvalue=-175.0, maxvalue=-119)
ysc = Scale.y_continuous(minvalue=29, maxvalue=50)
colsc = Scale.color_continuous(minvalue=-3, maxvalue=3)
layer1 = layer(seals, x=:Long, y=:Lat, xend=:Longb, yend=:Latb, color=:Angle,
Geom.vector)
plot(layer1, xsc, ysc, colsc, coord)
using Gadfly, RDatasets
set_default_plot_size(21cm, 8cm)
coord = Coord.cartesian(xmin=-2, xmax=2, ymin=-2, ymax=2)
p1 = plot(coord, z=(x,y)->x*exp(-(x^2+y^2)),
xmin=[-2], xmax=[2], ymin=[-2], ymax=[2],
# or: x=-2:0.25:2.0, y=-2:0.25:2.0,
Geom.vectorfield(scale=0.4, samples=17), Geom.contour(levels=6),
Scale.x_continuous(minvalue=-2.0, maxvalue=2.0),
Scale.y_continuous(minvalue=-2.0, maxvalue=2.0),
Guide.xlabel("x"), Guide.ylabel("y"), Guide.colorkey(title="z"))
volcano = Matrix{Float64}(dataset("datasets", "volcano"))
volc = volcano[1:4:end, 1:4:end]
coord = Coord.cartesian(xmin=1, xmax=22, ymin=1, ymax=16)
p2 = plot(coord, z=volc, x=1.0:22, y=1.0:16,
Geom.vectorfield(scale=0.05), Geom.contour(levels=7),
Scale.x_continuous(minvalue=1.0, maxvalue=22.0),
Scale.y_continuous(minvalue=1.0, maxvalue=16.0),
Guide.xlabel("x"), Guide.ylabel("y"),
Theme(key_position=:none))
hstack(p1,p2)
using Gadfly, RDatasets
set_default_plot_size(14cm, 8cm)
Dsing = dataset("lattice","singer")
Dsing[:Voice] = [x[1:5] for x in Dsing[:VoicePart]]
plot(Dsing, x=:VoicePart, y=:Height, color=:Voice, Geom.violin)
VoicePart
Soprano 1
Soprano 2
Alto 1
Alto 2
Tenor 1
Tenor 2
Bass 1
Bass 2
Sopra
Alto
Tenor
Bass
Voice
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
?
0
10
20
30
40
50
60
70
80
90
100
110
120
130
140
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
122
124
126
128
130
0
50
100
150
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
Height