Skip to content

Commit 811e061

Browse files
authored
Merge pull request #3 from lazarusA/more_examples
minor clean up
2 parents 57de892 + a88eb01 commit 811e061

File tree

137 files changed

+9497
-6029
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+9497
-6029
lines changed

.github/workflows/Deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
with:
4444
node-version: 18
4545
cache: npm # or pnpm / yarn
46-
cache-dependency-path: 'package.json' # this should be a package-lock.json file
46+
cache-dependency-path: 'package-lock.json' # this should be a package-lock.json file
4747
- name: Setup Pages
4848
uses: actions/configure-pages@v3
4949
- name: Install dependencies

docs/.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export default defineConfig({
5858
{ text: 'line_type', link: '/examples/2d/lines/line_type' },
5959
{ text: 'line_types', link: '/examples/2d/lines/line_types' },
6060
{ text: 'line_cb', link: '/examples/2d/lines/line_cb' },
61+
{ text: 'log scales', link: '/examples/2d/lines/log_scales' },
6162
{ text: 'dates', link: '/examples/2d/lines/dates' },
6263
{ text: 'dates_break2_axis', link: '/examples/2d/lines/dates_break2_axis' },
6364
{ text: 'dates_break3_axis', link: '/examples/2d/lines/dates_break3_axis' }

docs/examples/2d/contours/contour.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,30 @@
22

33

44
```julia
5-
using Gnuplot, Random
6-
Random.seed!(123)
7-
let
8-
x = y = -15:0.33:15
9-
fz(x,y) = sin.(sqrt.(x.^2 + y.^2))./sqrt.(x.^2+y.^2)
10-
fxy = [fz(x,y) for x in x, y in y]
11-
@gsp x y fxy "w l lc palette" "set view map"
12-
@gsp :- "set contour base;set key off" "set auto fix"
13-
@gsp :- "set cntrparam levels 15" "unset surface"
14-
@gsp :- xlab = "x" ylab = "y"
15-
end
5+
using Gnuplot
6+
empty!(Gnuplot.options.init)
7+
push!( Gnuplot.options.init, linetypes(:Set1_5, lw=1.5, ps=1.5))
8+
function saveas(file; sx=550, sy=350, fs=0.8, term="svg")
9+
Gnuplot.save(term="$(term) size $(sx),$(sy) fontscale $(fs)", "$(file).svg")
10+
end;
1611
```
1712

1813

19-
```
20-
"assets/contour001.svg"
14+
<a id='Contour-plot'></a>
15+
16+
## Contour plot
17+
18+
19+
```julia
20+
x = y = -15:0.33:15
21+
fz(x,y) = sin.(sqrt.(x.^2 + y.^2))./sqrt.(x.^2+y.^2)
22+
fxy = [fz(x,y) for x in x, y in y]
23+
@gsp x y fxy "w l lc palette" "set view map"
24+
@gsp :- "set contour base;set key off" "set auto fix"
25+
@gsp :- "set cntrparam levels 15" "unset surface"
26+
@gsp :- xlab = "x" ylab = "y"
2127
```
2228

2329

24-
![](assets/contour001.svg)
30+
![](contour001.svg)
2531

docs/examples/2d/contours/contour_egg.md

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,33 @@
22

33

44
```julia
5-
using Gnuplot, Random
6-
Random.seed!(123)
7-
let
8-
x = -1:0.05:1
9-
y = -1.5:0.05:2
10-
egg(x,y) = x^2 + y^2/(1.4 + y/5)^2
11-
segg = [egg(x,y) for x in x, y in y]
12-
@gsp x y segg "w l lc palette" palette(:thermal; rev= true) "set view map"
13-
@gsp :- "set contour base;set key off" "set auto fix"
14-
@gsp :- "set cntrparam levels incremental 0,0.01,1" "unset surface"
15-
@gsp :- xrange = (-1.2,1.2) yrange = (-1.5,2) cbrange =(0,1)
16-
@gsp :- xlab = "x" ylab = "y" "set size ratio -1"
17-
end
5+
using Gnuplot
6+
empty!(Gnuplot.options.init)
7+
push!( Gnuplot.options.init, linetypes(:Set1_5, lw=1.5, ps=1.5))
8+
function saveas(file; sx=550, sy=350, fs=0.8, term="svg")
9+
Gnuplot.save(term="$(term) size $(sx),$(sy) fontscale $(fs)", "$(file).svg")
10+
end;
1811
```
1912

2013

21-
```
22-
"assets/contour002.svg"
14+
<a id='Contour-plot:-egg-shape'></a>
15+
16+
## Contour plot: egg shape
17+
18+
19+
```julia
20+
x = -1:0.05:1
21+
y = -1.5:0.05:2
22+
egg(x,y) = x^2 + y^2/(1.4 + y/5)^2
23+
segg = [egg(x,y) for x in x, y in y]
24+
@gsp x y segg "w l lc palette" palette(:thermal; rev= true) "set view map"
25+
@gsp :- "set contour base;set key off" "set auto fix"
26+
@gsp :- "set cntrparam levels incremental 0,0.01,1" "unset surface"
27+
@gsp :- xrange = (-1.2,1.2) yrange = (-1.5,2) cbrange =(0,1)
28+
@gsp :- xlab = "x" ylab = "y" "set size ratio -1"
29+
saveas("contour002");
2330
```
2431

2532

26-
![](assets/contour002.svg)
33+
![](contour002.svg)
2734

docs/examples/2d/filledcu/between.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,26 @@
33

44
```julia
55
using Gnuplot
6-
let
7-
x = LinRange(-10,10,200)
8-
@gp x sin.(x) sin.(x) .+ 1 "with filledcu lc '#56B4E9' fs transparent solid 0.3"
9-
@gp :- x cos.(x) 1 .+ cos.(x) "with filledcu lc 'red' fs transparent solid 0.5"
10-
end
6+
empty!(Gnuplot.options.init)
7+
push!( Gnuplot.options.init, linetypes(:Set1_5, lw=1.5, ps=1.5))
8+
function saveas(file; sx=550, sy=350, fs=0.8, term="svg")
9+
Gnuplot.save(term="$(term) size $(sx),$(sy) fontscale $(fs)", "$(file).svg")
10+
end;
1111
```
1212

1313

14-
```
15-
"assets/filled002.svg"
14+
<a id='Filled-Between-curves'></a>
15+
16+
## Filled Between curves
17+
18+
19+
```julia
20+
x = LinRange(-10,10,200)
21+
@gp x sin.(x) sin.(x) .+ 1 "with filledcu lc '#56B4E9' fs transparent solid 0.3"
22+
@gp :- x cos.(x) 1 .+ cos.(x) "with filledcu lc 'red' fs transparent solid 0.5"
23+
saveas("filled002");
1624
```
1725

1826

19-
![](assets/filled002.svg)
27+
![](filled002.svg)
2028

docs/examples/2d/filledcu/filled.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,30 @@
33

44
```julia
55
using Gnuplot
6-
let
7-
x = LinRange(-10,10,200)
8-
fg(x,μ,σ) = exp.(.-(x.-μ).^2 ./(2σ^2))./*√(2π))
9-
@gp x fg(x, 0.25, 1.5) "w filledcurves lc '#E69F00' t '0.25,1.5'"
10-
@gp :- "set style fill transparent solid 0.5 noborder"
11-
@gp :- "set key title 'μ,σ' box 3" xlab = "x" ylab = "P(x)"
12-
@gp :- x fg(x, 2, 1) "w filledcu lc rgb '#56B4E9' t '2,1' fs transparent solid 0.25"
13-
@gp :- x fg(x, -1, 2) "w filledcu lc '#009E73' t '-1,2' fs transparent solid 0.1"
14-
end
6+
empty!(Gnuplot.options.init)
7+
push!( Gnuplot.options.init, linetypes(:Set1_5, lw=1.5, ps=1.5))
8+
function saveas(file; sx=550, sy=350, fs=0.8, term="svg")
9+
Gnuplot.save(term="$(term) size $(sx),$(sy) fontscale $(fs)", "$(file).svg")
10+
end;
1511
```
1612

1713

18-
```
19-
"assets/filled001.svg"
14+
<a id='Filled-curves'></a>
15+
16+
## Filled curves
17+
18+
19+
```julia
20+
x = LinRange(-10,10,200)
21+
fg(x,μ,σ) = exp.(.-(x.-μ).^2 ./(2σ^2))./*√(2π))
22+
@gp x fg(x, 0.25, 1.5) "w filledcurves lc '#E69F00' t '0.25,1.5'"
23+
@gp :- "set style fill transparent solid 0.5 noborder"
24+
@gp :- "set key title 'μ,σ' box 3" xlab = "x" ylab = "P(x)"
25+
@gp :- x fg(x, 2, 1) "w filledcu lc rgb '#56B4E9' t '2,1' fs transparent solid 0.25"
26+
@gp :- x fg(x, -1, 2) "w filledcu lc '#009E73' t '-1,2' fs transparent solid 0.1"
27+
saveas("filled001");
2028
```
2129

2230

23-
![](assets/filled001.svg)
31+
![](filled001.svg)
2432

docs/examples/2d/filledcu/glow.md

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,55 @@
33

44
```julia
55
using Gnuplot
6-
let
7-
x = 0:0.3:4
8-
a = exp.(- x)
9-
b = exp.(- x.^2)
10-
# theme
11-
function gp_theme(bgcolor = "#212946"; borderc ="white",
12-
ticsc = "white", ylabc = "white", gridst = 4,
13-
xlabc = "white", gridc = "#2A3459", labc = "white")
14-
bgcp1 = "set object rectangle from screen 0,0 to screen 1,1"
15-
bgcp2 = " behind fc '$(bgcolor)' fs solid noborder"
16-
bgcolor = bgcp1*bgcp2
17-
@gp :- "set border lw 1 lc '$(borderc)'"
18-
@gp :- "set tics textcolor rgb '$(ticsc)'"
19-
@gp :- bgcolor
20-
@gp :- "set ylabel 'y' textcolor '$(ylabc)'"
21-
@gp :- "set xlabel 'x' textcolor '$(xlabc)'"
22-
@gp :- "set grid ls 1 lc '$(gridc)' dt $(gridst)"
23-
@gp :- "set key t r textcolor '$(labc)'"
24-
end
25-
26-
# plot
27-
@gp x a "w linespoints lw 1 lc '#08F7FE' pt 7 t 'e^{-x}'"
28-
@gp :- x b "w linespoints lw 1 lc '#FFE64D' pt 7 t 'e^{-x^2}'"
29-
# glow effect
30-
for i in 1:10
31-
@gp :- x a "w l lw $(1 + 1.05*i) lc '#F508F7FE' t ''"
32-
@gp :- x b "w l lw $(1 + 1.05*i) lc '#F5FFE64D' t ''" :-
33-
end
34-
# fill between
35-
@gp(:-,x, a, "w filledcu y=0 lw 1 lc '#08F7FE' t ''",
36-
"set style fill transparent solid 0.08 noborder")
37-
@gp(:-, x, a, b, "w filledcu lw 1 lc '#FFE64D' t ''")
38-
gp_theme("black")
39-
end
6+
empty!(Gnuplot.options.init)
7+
push!( Gnuplot.options.init, linetypes(:Set1_5, lw=1.5, ps=1.5))
8+
function saveas(file; sx=550, sy=350, fs=0.8, term="svg")
9+
Gnuplot.save(term="$(term) size $(sx),$(sy) fontscale $(fs)", "$(file).svg")
10+
end;
4011
```
4112

4213

43-
```
44-
"assets/filled003.svg"
14+
<a id='Filled-Between-curves:-glow-effect'></a>
15+
16+
## Filled Between curves: glow effect
17+
18+
19+
```julia
20+
x = 0:0.3:4
21+
a = exp.(- x)
22+
b = exp.(- x.^2)
23+
# theme
24+
function gp_theme(bgcolor = "#212946"; borderc ="white",
25+
ticsc = "white", ylabc = "white", gridst = 4,
26+
xlabc = "white", gridc = "#2A3459", labc = "white")
27+
bgcp1 = "set object rectangle from screen 0,0 to screen 1,1"
28+
bgcp2 = " behind fc '$(bgcolor)' fs solid noborder"
29+
bgcolor = bgcp1*bgcp2
30+
@gp :- "set border lw 1 lc '$(borderc)'"
31+
@gp :- "set tics textcolor rgb '$(ticsc)'"
32+
@gp :- bgcolor
33+
@gp :- "set ylabel 'y' textcolor '$(ylabc)'"
34+
@gp :- "set xlabel 'x' textcolor '$(xlabc)'"
35+
@gp :- "set grid ls 1 lc '$(gridc)' dt $(gridst)"
36+
@gp :- "set key t r textcolor '$(labc)'"
37+
end
38+
39+
# plot
40+
@gp x a "w linespoints lw 1 lc '#08F7FE' pt 7 t 'e^{-x}'"
41+
@gp :- x b "w linespoints lw 1 lc '#FFE64D' pt 7 t 'e^{-x^2}'"
42+
# glow effect
43+
for i in 1:10
44+
@gp :- x a "w l lw $(1 + 1.05*i) lc '#F508F7FE' t ''"
45+
@gp :- x b "w l lw $(1 + 1.05*i) lc '#F5FFE64D' t ''" :-
46+
end
47+
# fill between
48+
@gp(:-,x, a, "w filledcu y=0 lw 1 lc '#08F7FE' t ''",
49+
"set style fill transparent solid 0.08 noborder")
50+
@gp(:-, x, a, b, "w filledcu lw 1 lc '#FFE64D' t ''")
51+
gp_theme("black")
52+
saveas("filled003");
4553
```
4654

4755

48-
![](assets/filled003.svg)
56+
![](filled003.svg)
4957

docs/examples/2d/heatmaps/heatmap.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11

22

33

4+
```julia
5+
using Gnuplot
6+
empty!(Gnuplot.options.init)
7+
push!( Gnuplot.options.init, linetypes(:Set1_5, lw=1.5, ps=1.5))
8+
function saveas(file; sx=550, sy=350, fs=0.8, term="svg")
9+
Gnuplot.save(term="$(term) size $(sx),$(sy) fontscale $(fs)", "$(file).svg")
10+
end;
11+
```
12+
13+
14+
<a id='image-plot'></a>
15+
16+
## image plot
17+
18+
419
```julia
520
using Gnuplot, Random
621
Random.seed!(1234)
@@ -10,9 +25,9 @@ matrix = randn(50,60)
1025

1126

1227
```
13-
"assets/heatmap001.svg"
28+
"heatmap001.svg"
1429
```
1530

1631

17-
![](assets/heatmap001.svg)
32+
![](heatmap001.svg)
1833

docs/examples/2d/heatmaps/heatmap_cblabel.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,33 @@
22

33

44
```julia
5-
using Gnuplot, Random
6-
Random.seed!(123)
7-
let
8-
test = rand(50,50)
9-
@gp "set auto fix" "set size square" :-
10-
@gp :- test "w image pixels notit" """set cblabel "CBTitle \\n (my unit)" """ :-
11-
@gp :- "set cblabel offset -6.5, 10 font ',8' textcolor lt 3 rotate by 0" :-
12-
@gp :- palette(:plasma) :-
13-
@gp :- "set tmargin at screen 0.80"
14-
end
5+
using Gnuplot
6+
empty!(Gnuplot.options.init)
7+
push!( Gnuplot.options.init, linetypes(:Set1_5, lw=1.5, ps=1.5))
8+
function saveas(file; sx=550, sy=350, fs=0.8, term="svg")
9+
Gnuplot.save(term="$(term) size $(sx),$(sy) fontscale $(fs)", "$(file).svg")
10+
end;
1511
```
1612

1713

18-
```
19-
"assets/heatmap004.svg"
14+
<a id='Heatmap:-colorbar'></a>
15+
16+
## Heatmap: colorbar
17+
18+
19+
```julia
20+
using Random
21+
Random.seed!(123)
22+
23+
test = rand(50,50)
24+
@gp "set auto fix" "set size square" :-
25+
@gp :- test "w image pixels notit" """set cblabel "CBTitle \\n (my unit)" """ :-
26+
@gp :- "set cblabel offset -6.5, 10 font ',8' textcolor lt 3 rotate by 0" :-
27+
@gp :- palette(:plasma) :-
28+
@gp :- "set tmargin at screen 0.80"
29+
saveas("heatmap004");
2030
```
2131

2232

23-
![](assets/heatmap004.svg)
33+
![](heatmap004.svg)
2434

0 commit comments

Comments
 (0)