Skip to content

Commit eb204da

Browse files
committed
improve user manual - docs
1 parent b5b6f22 commit eb204da

File tree

7 files changed

+283
-9
lines changed

7 files changed

+283
-9
lines changed

docs/assets/ohlc.csv

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
close,date,high,low,open,ret,signal,c
2+
30.04,2009-06-01,30.05,28.45,28.7,-4.89396411092985,short,green
3+
29.63,2009-06-02,30.13,28.3,30.04,-0.322580645161295,short,red
4+
31.02,2009-06-03,31.79,29.62,29.62,3.68663594470045,short,green
5+
30.18,2009-06-04,31.02,29.92,31.02,4.51010886469673,short,red
6+
29.62,2009-06-05,30.81,28.85,29.39,6.08424336973478,short,green
7+
29.77,2009-06-08,31.82,26.41,30.84,1.2539184952978,short,red
8+
28.27,2009-06-09,29.77,27.79,29.77,-5.02431118314424,short,red
9+
28.46,2009-06-10,29.74,26.9,26.9,-5.46623794212217,short,green
10+
28.11,2009-06-11,28.11,26.81,27.36,-8.3743842364532,short,green
11+
28.15,2009-06-12,28.5,27.73,28.08,-5.52763819095477,short,green
12+
30.81,2009-06-15,31.09,29.64,29.7,3.4920634920635,long,green
13+
32.68,2009-06-16,32.75,30.07,30.81,0.155038759689914,short,green
14+
31.54,2009-06-17,32.77,30.64,31.19,5.82822085889571,short,green
15+
30.03,2009-06-18,31.54,29.6,31.54,8.17610062893082,short,red
16+
27.99,2009-06-19,29.32,27.56,29.16,8.59872611464968,short,red
17+
31.17,2009-06-22,32.05,30.3,30.4,15.4907975460123,short,green
18+
30.58,2009-06-23,31.54,27.83,31.3,11.7370892018779,short,red
19+
29.05,2009-06-24,30.58,28.79,30.58,-10.4234527687296,long,red
20+
26.36,2009-06-25,29.56,26.3,29.45,0.0,long,red
21+
25.93,2009-06-26,27.22,25.76,27.09,0.0,long,red
22+
25.35,2009-06-29,27.18,25.29,25.93,5.26315789473684,long,red
23+
26.35,2009-06-30,27.38,25.02,25.36,6.73758865248228,long,green
24+
26.22,2009-07-01,26.31,24.8,25.73,7.83645655877341,long,green
25+
27.95,2009-07-02,28.62,26.22,26.22,2.76422764227643,long,green
26+
29.0,2009-07-06,30.6,28.99,30.32,-2.14521452145214,short,red
27+
30.85,2009-07-07,30.94,28.9,29.0,3.03514376996805,short,green
28+
31.3,2009-07-08,33.05,30.43,30.85,5.68720379146919,short,green
29+
29.78,2009-07-09,30.49,29.28,30.23,8.22784810126583,short,red
30+
29.02,2009-07-10,30.34,28.82,29.78,8.64779874213836,short,red
31+
26.31,2009-07-13,29.24,25.42,28.36,7.32899022801303,short,red
32+
25.02,2009-07-14,26.84,24.99,26.31,7.30897009966778,short,red
33+
25.89,2009-07-15,26.06,23.83,25.05,0.0,neutral,green
34+
25.42,2009-07-16,26.18,24.51,25.96,-9.82758620689656,long,red
35+
24.34,2009-07-17,25.55,23.88,25.42,-10.8433734939759,long,red
36+
24.4,2009-07-20,25.42,24.26,25.06,-7.55711775043936,long,red
37+
23.87,2009-07-21,25.14,23.81,24.28,-2.5089605734767,long,red
38+
23.47,2009-07-22,24.14,23.24,24.05,0.915750915750916,long,red
39+
23.43,2009-07-23,24.05,23.21,23.71,2.47148288973383,long,red
40+
23.09,2009-07-24,23.87,23.0,23.87,4.22264875239922,long,red
41+
24.28,2009-07-27,24.86,24.02,24.06,-0.189393939393929,long,green
42+
25.01,2009-07-28,25.61,24.28,24.28,-4.37956204379562,long,green
43+
25.61,2009-07-29,26.18,25.41,25.47,-4.48504983388705,long,green
44+
25.4,2009-07-30,25.76,24.85,25.4,-1.70357751277683,long,red
45+
25.92,2009-07-31,26.22,24.93,25.4,5.06756756756757,short,green

docs/gallery/Plots/BoxPlot/boxplot.jl

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,25 @@ sgplot(ds, BoxPlot(y=1:10, category=:Category,
7878
yaxis=Axis(show=false),
7979
legend=false,
8080
clip=false
81-
)
81+
)
82+
83+
# Application - Dubai weather
84+
dubai_weather = filereader(joinpath(dirname(pathof(StatisticalGraphics)),
85+
"..", "docs", "assets", "dubai_weather.csv"),
86+
types=Dict(1 =>Date))
87+
88+
modify!(dubai_weather, :date=>byrow(week)=>:Week)
89+
setformat!(dubai_weather, :date=>month)
90+
91+
sgplot(
92+
dubai_weather,
93+
[
94+
BoxPlot(y=[:min, :max], category=:date, outliers=true),
95+
BoxPlot(y=:pressure, category=:Week, opacity=0.5, y2axis=true, outliers=true, x2axis=true)
96+
],
97+
xaxis=Axis(title="Month"),
98+
yaxis=Axis(title="Temperature"),
99+
y2axis=Axis(title="Pressure", d3format="f"),
100+
x2axis=Axis(values=3:4:53),
101+
height=600
102+
)

docs/gallery/Plots/Line/line3.jl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ sgplot(dubai_weather, Line(x=:date, y=:pressure, breaks=true), xaxis=Axis(type=:
2323

2424
sgplot(dubai_weather, [Line(x=:date, y=:pressure, breaks=true), Scatter(x=:date, y=:pressure)], xaxis=Axis(type=:date))
2525

26+
# multiple axes
27+
28+
sgplot(
29+
dubai_weather,
30+
[
31+
Band(x=:date, lower=:min, upper=:max),
32+
Line(x=:date, y=:min, color="#4682b4", thickness=1),
33+
Line(x=:date, y=:max, color="#ff7f0e", thickness=0.5),
34+
Line(x=:date, y=:pressure, color="#2ca02c", y2axis=true, breaks=true),
35+
Scatter(x=:date, y=:pressure, outlinecolor="#2ca02c", size=10, y2axis=true)
36+
],
37+
xaxis=Axis(offset=10, type=:date, grid=true, griddash=[1, 1], title="Date"),
38+
yaxis=Axis(offset=10, grid=true, griddash=[1, 1], title="Temperature(°C)"),
39+
y2axis=Axis(offset=10, title="Pressure")
40+
)
41+
2642
# The `interpolate` keyword argument can be used to intepolate line,
2743

2844
ds = Dataset(x=1:10, y=rand(10))
@@ -36,7 +52,7 @@ color=Dict( :linear=>:blue,
3652
sgplot(ds, [
3753
[
3854
Line(x=:x, y=:y, interpolate=v, thickness=2, color=color[v])
39-
for v in [:linear, :basis, :step, :natural]
55+
for v in keys(color)
4056
]; Scatter(x=:x, y=:y, color=:steelblue, size=100)
4157
],
4258
clip=false

docs/gallery/Plots/Pie/pie.jl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# ---
2+
# title: Pie chart
3+
# id: demo_pie
4+
# description: Using the `Pie` mark to produce Pie charts
5+
# cover: assets/pie_1.svg
6+
# ---
7+
8+
using InMemoryDatasets, StatisticalGraphics, DLMReader
9+
10+
svg("assets/pie_1.svg", sgplot(Dataset(x=1:4, y=[1,1,1.5,2]), Pie(category=:x, response=:y), width=150, height=100, legend=false)) #hide #md
11+
12+
# Pie chart shows the frequency of `category` in a data set as proportional slices of a whole circle
13+
14+
sgplot(Dataset(x=[1,2,3,3,4,4,4]),
15+
Pie(category=:x)
16+
)
17+
18+
# Users can pass a column as response for computing the slices based on the aggregated values of the passed column. The `stat` keyword argument is used to aggregate the values.
19+
20+
cars = filereader(joinpath(dirname(pathof(StatisticalGraphics)),
21+
"..", "docs", "assets", "cars.csv"),
22+
types=Dict(9=>Date))
23+
24+
25+
sgplot(cars,
26+
Pie(category=:Origin, response=:Acceleration, stat=IMD.mean)
27+
)
28+
29+
# A column can be passed as `group` to produce a nested pie chart
30+
31+
sgplot(cars,
32+
33+
Pie(category=:Cylinders,
34+
group=:Origin,
35+
groupspace=0.05,
36+
)
37+
)
38+
39+
# The donut chart is produced by passing `innerradius`
40+
41+
sgplot(cars,
42+
Pie(category=:Origin, innerradius=0.4)
43+
)
44+
45+
# Slices can be labeled based on their frequency and/or category
46+
47+
48+
sgplot(cars,
49+
Pie(category=:Origin, label=:both)
50+
)

docs/gallery/Plots/Pie/pie2.jl

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# ---
2+
# title: Other features
3+
# id: demo_pie2
4+
# description: Customising Pie charts
5+
# cover: assets/pie_2.svg
6+
# ---
7+
8+
using InMemoryDatasets, StatisticalGraphics, DLMReader
9+
10+
svg("assets/pie_2.svg", sgplot( Dataset(x=[0.6, 0.4], done=["60%", missing]),[Pie(category=:x, response=:x,innerradius=0.7,startangle=-110,endangle=110,outlinecolor=:black,colormodel=[:steelblue, :transparent]),Pie(category=:done,opacity=0,label=:category,labelpos=0,labelangle=0,labelsize=20,labelcolor=:gray)],legend=false,clip=false,width=150, height=100,)) #hide #md
11+
12+
13+
# Create gauge with changing the values of start/end angles
14+
15+
ds = Dataset(x=[0.6, 0.4], done=["60%", missing])
16+
sgplot(ds,
17+
[
18+
Pie(category=:x, response=:x,
19+
innerradius=0.7,
20+
startangle=-110,
21+
endangle=110,
22+
outlinecolor=:black,
23+
colormodel=[:steelblue, :transparent]
24+
),
25+
Pie(category=:done,
26+
opacity=0,
27+
label=:category,
28+
labelpos=0,
29+
labelangle=0,
30+
labelsize=100,
31+
labelcolor=:gray
32+
)
33+
],
34+
legend=false
35+
36+
)
37+
38+
# Controlling the color model
39+
40+
ds = Dataset(x=1:39, y=[rand(1:39, 30) for _ in 1:39])
41+
flatten!(ds, :y)
42+
insertcols!(ds, :z=>rand(nrow(ds)))
43+
44+
sgplot(ds,
45+
Pie(category=:x, group=:y,
46+
response=:z,
47+
groupspace=0,
48+
innerradius=0.1,
49+
piecorner=10,
50+
colormodel=[:black, :white]),
51+
legend=false,
52+
)
53+
54+
# Nested Pie chart
55+
56+
cars = filereader(joinpath(dirname(pathof(StatisticalGraphics)),
57+
"..", "docs", "assets", "cars.csv"),
58+
types=Dict(9=>Date))
59+
60+
sgplot(cars,
61+
[
62+
Pie(category=:Cylinders,
63+
group=:Origin,
64+
groupspace=0.05,
65+
innerradius=0.1,
66+
label=:category,
67+
labelangle=0,
68+
piecorner=5
69+
),
70+
Pie(category=:Origin,
71+
group=:Origin,
72+
innerradius=0.1,
73+
opacity=0,
74+
endangle=0.1,
75+
groupspace=0.05,
76+
label=:category,
77+
labelpos=1,
78+
labelbaseline=:bottom,
79+
labelsize=8
80+
)
81+
],
82+
legend=false,
83+
clip=false
84+
)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# ---
2+
# title: Line segments
3+
# id: demo_segment
4+
# description: Using the `Segment` mark to produce line segments
5+
# cover: assets/segment_1.svg
6+
# ---
7+
8+
using InMemoryDatasets, StatisticalGraphics, DLMReader
9+
10+
svg("assets/segment_1.svg", sgplot(Dataset(y=1:1:4, low=rand(4), up=rand(4) .+ 1.3), [Segment(y=:y, lower=:low, upper=:up), Scatter(y=:y, x=:low, symbol=:stroke, angle=90), Scatter(y=:y, x=:up, symbol=:stroke, angle=90), RefLine(values=1, axis=:xaxis, dash=[2])], width=100, height=100, xaxis=Axis(offset=0, domain=true,labelcolor=:black, tickcolor=:black,titlecolor=:white, padding=10), yaxis=Axis(offset=0,domain=true,labelcolor=:black, tickcolor=:black,titlecolor=:white, tickcount=5, padding =10), legend=false, clip=false)) #hide #md
11+
12+
# `Segment` produces line segments. For each segment the main coordinate and the lower and the upper value must be supplied.
13+
14+
ds = Dataset(y=1:10, low=rand(10), up=rand(10) .+ 1.3)
15+
sgplot(ds,
16+
Segment(y=:y, lower=:low, upper=:up),
17+
clip=false
18+
)
19+
20+
21+
22+
# Overlay Scatter plot
23+
24+
cars = filereader(joinpath(dirname(pathof(StatisticalGraphics)),
25+
"..", "docs", "assets", "cars.csv"),
26+
types=Dict(9=>Date))
27+
cars_sum = combine(groupby(cars, :Origin), 1=>[IMD.mean, IMD.maximum, IMD.minimum])
28+
29+
sgplot(cars_sum,
30+
[
31+
Segment(y=:Origin, lower=r"^min", upper=r"^max"),
32+
Scatter(y=:Origin, x=r"^mean"),
33+
Scatter(y=:Origin, x=r"^min", symbol=:stroke, angle=90),
34+
Scatter(y=:Origin, x=r"^max", symbol=:stroke, angle=90)
35+
],
36+
xaxis=Axis(title="Acceleration", padding=10),
37+
yaxis=Axis(padding=.5)
38+
)
39+
40+
# `Segment` like other plots accept `group`.
41+
42+
ohlc = filereader(joinpath(dirname(pathof(StatisticalGraphics)),
43+
"..", "docs", "assets", "ohlc.csv"),
44+
types = Dict(2=>Date, 8=>Symbol))
45+
46+
sgplot(ohlc,
47+
Segment(x=:date, lower=:low, upper=:high, group=:c),
48+
groupcolormodel=ohlc[:, :c],
49+
xaxis=Axis(type=:time),
50+
yaxis=Axis(title="")
51+
)
52+
53+
# Candlestick Chart
54+
55+
sgplot(ohlc,
56+
[
57+
Segment(x=:date, lower=:open, upper=:close, group=:c, thickness=5),
58+
Segment(x=:date, lower=:low, upper=:high, group=:c)
59+
],
60+
groupcolormodel=ohlc[:, :c],
61+
xaxis=Axis(type=:time),
62+
yaxis=Axis(title=""),
63+
legend=false
64+
)

docs/gallery/Plots/config.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
{
2-
"theme": "list",
3-
"order":[
4-
"Line",
5-
"Scatter",
6-
"BoxPlot",
7-
"Bar"
8-
]
2+
"theme": "list"
93
}

0 commit comments

Comments
 (0)