Skip to content

Commit

Permalink
Merge pull request #3 from lazarusA/more_examples
Browse files Browse the repository at this point in the history
minor clean up
  • Loading branch information
lazarusA authored Jan 21, 2024
2 parents 57de892 + a88eb01 commit 811e061
Show file tree
Hide file tree
Showing 137 changed files with 9,497 additions and 6,029 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
with:
node-version: 18
cache: npm # or pnpm / yarn
cache-dependency-path: 'package.json' # this should be a package-lock.json file
cache-dependency-path: 'package-lock.json' # this should be a package-lock.json file
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Install dependencies
Expand Down
1 change: 1 addition & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default defineConfig({
{ text: 'line_type', link: '/examples/2d/lines/line_type' },
{ text: 'line_types', link: '/examples/2d/lines/line_types' },
{ text: 'line_cb', link: '/examples/2d/lines/line_cb' },
{ text: 'log scales', link: '/examples/2d/lines/log_scales' },
{ text: 'dates', link: '/examples/2d/lines/dates' },
{ text: 'dates_break2_axis', link: '/examples/2d/lines/dates_break2_axis' },
{ text: 'dates_break3_axis', link: '/examples/2d/lines/dates_break3_axis' }
Expand Down
34 changes: 20 additions & 14 deletions docs/examples/2d/contours/contour.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,30 @@


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


```
"assets/contour001.svg"
<a id='Contour-plot'></a>

## Contour plot


```julia
x = y = -15:0.33:15
fz(x,y) = sin.(sqrt.(x.^2 + y.^2))./sqrt.(x.^2+y.^2)
fxy = [fz(x,y) for x in x, y in y]
@gsp x y fxy "w l lc palette" "set view map"
@gsp :- "set contour base;set key off" "set auto fix"
@gsp :- "set cntrparam levels 15" "unset surface"
@gsp :- xlab = "x" ylab = "y"
```


![](assets/contour001.svg)
![](contour001.svg)

File renamed without changes
File renamed without changes
39 changes: 23 additions & 16 deletions docs/examples/2d/contours/contour_egg.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,33 @@


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


```
"assets/contour002.svg"
<a id='Contour-plot:-egg-shape'></a>

## Contour plot: egg shape


```julia
x = -1:0.05:1
y = -1.5:0.05:2
egg(x,y) = x^2 + y^2/(1.4 + y/5)^2
segg = [egg(x,y) for x in x, y in y]
@gsp x y segg "w l lc palette" palette(:thermal; rev= true) "set view map"
@gsp :- "set contour base;set key off" "set auto fix"
@gsp :- "set cntrparam levels incremental 0,0.01,1" "unset surface"
@gsp :- xrange = (-1.2,1.2) yrange = (-1.5,2) cbrange =(0,1)
@gsp :- xlab = "x" ylab = "y" "set size ratio -1"
saveas("contour002");
```


![](assets/contour002.svg)
![](contour002.svg)

24 changes: 16 additions & 8 deletions docs/examples/2d/filledcu/between.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,26 @@

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


```
"assets/filled002.svg"
<a id='Filled-Between-curves'></a>

## Filled Between curves


```julia
x = LinRange(-10,10,200)
@gp x sin.(x) sin.(x) .+ 1 "with filledcu lc '#56B4E9' fs transparent solid 0.3"
@gp :- x cos.(x) 1 .+ cos.(x) "with filledcu lc 'red' fs transparent solid 0.5"
saveas("filled002");
```


![](assets/filled002.svg)
![](filled002.svg)

32 changes: 20 additions & 12 deletions docs/examples/2d/filledcu/filled.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,30 @@

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


```
"assets/filled001.svg"
<a id='Filled-curves'></a>

## Filled curves


```julia
x = LinRange(-10,10,200)
fg(x,μ,σ) = exp.(.-(x.-μ).^2 ./(2σ^2))./*√(2π))
@gp x fg(x, 0.25, 1.5) "w filledcurves lc '#E69F00' t '0.25,1.5'"
@gp :- "set style fill transparent solid 0.5 noborder"
@gp :- "set key title 'μ,σ' box 3" xlab = "x" ylab = "P(x)"
@gp :- x fg(x, 2, 1) "w filledcu lc rgb '#56B4E9' t '2,1' fs transparent solid 0.25"
@gp :- x fg(x, -1, 2) "w filledcu lc '#009E73' t '-1,2' fs transparent solid 0.1"
saveas("filled001");
```


![](assets/filled001.svg)
![](filled001.svg)

File renamed without changes
File renamed without changes
File renamed without changes
82 changes: 45 additions & 37 deletions docs/examples/2d/filledcu/glow.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,55 @@

```julia
using Gnuplot
let
x = 0:0.3:4
a = exp.(- x)
b = exp.(- x.^2)
# theme
function gp_theme(bgcolor = "#212946"; borderc ="white",
ticsc = "white", ylabc = "white", gridst = 4,
xlabc = "white", gridc = "#2A3459", labc = "white")
bgcp1 = "set object rectangle from screen 0,0 to screen 1,1"
bgcp2 = " behind fc '$(bgcolor)' fs solid noborder"
bgcolor = bgcp1*bgcp2
@gp :- "set border lw 1 lc '$(borderc)'"
@gp :- "set tics textcolor rgb '$(ticsc)'"
@gp :- bgcolor
@gp :- "set ylabel 'y' textcolor '$(ylabc)'"
@gp :- "set xlabel 'x' textcolor '$(xlabc)'"
@gp :- "set grid ls 1 lc '$(gridc)' dt $(gridst)"
@gp :- "set key t r textcolor '$(labc)'"
end

# plot
@gp x a "w linespoints lw 1 lc '#08F7FE' pt 7 t 'e^{-x}'"
@gp :- x b "w linespoints lw 1 lc '#FFE64D' pt 7 t 'e^{-x^2}'"
# glow effect
for i in 1:10
@gp :- x a "w l lw $(1 + 1.05*i) lc '#F508F7FE' t ''"
@gp :- x b "w l lw $(1 + 1.05*i) lc '#F5FFE64D' t ''" :-
end
# fill between
@gp(:-,x, a, "w filledcu y=0 lw 1 lc '#08F7FE' t ''",
"set style fill transparent solid 0.08 noborder")
@gp(:-, x, a, b, "w filledcu lw 1 lc '#FFE64D' t ''")
gp_theme("black")
end
empty!(Gnuplot.options.init)
push!( Gnuplot.options.init, linetypes(:Set1_5, lw=1.5, ps=1.5))
function saveas(file; sx=550, sy=350, fs=0.8, term="svg")
Gnuplot.save(term="$(term) size $(sx),$(sy) fontscale $(fs)", "$(file).svg")
end;
```


```
"assets/filled003.svg"
<a id='Filled-Between-curves:-glow-effect'></a>

## Filled Between curves: glow effect


```julia
x = 0:0.3:4
a = exp.(- x)
b = exp.(- x.^2)
# theme
function gp_theme(bgcolor = "#212946"; borderc ="white",
ticsc = "white", ylabc = "white", gridst = 4,
xlabc = "white", gridc = "#2A3459", labc = "white")
bgcp1 = "set object rectangle from screen 0,0 to screen 1,1"
bgcp2 = " behind fc '$(bgcolor)' fs solid noborder"
bgcolor = bgcp1*bgcp2
@gp :- "set border lw 1 lc '$(borderc)'"
@gp :- "set tics textcolor rgb '$(ticsc)'"
@gp :- bgcolor
@gp :- "set ylabel 'y' textcolor '$(ylabc)'"
@gp :- "set xlabel 'x' textcolor '$(xlabc)'"
@gp :- "set grid ls 1 lc '$(gridc)' dt $(gridst)"
@gp :- "set key t r textcolor '$(labc)'"
end

# plot
@gp x a "w linespoints lw 1 lc '#08F7FE' pt 7 t 'e^{-x}'"
@gp :- x b "w linespoints lw 1 lc '#FFE64D' pt 7 t 'e^{-x^2}'"
# glow effect
for i in 1:10
@gp :- x a "w l lw $(1 + 1.05*i) lc '#F508F7FE' t ''"
@gp :- x b "w l lw $(1 + 1.05*i) lc '#F5FFE64D' t ''" :-
end
# fill between
@gp(:-,x, a, "w filledcu y=0 lw 1 lc '#08F7FE' t ''",
"set style fill transparent solid 0.08 noborder")
@gp(:-, x, a, b, "w filledcu lw 1 lc '#FFE64D' t ''")
gp_theme("black")
saveas("filled003");
```


![](assets/filled003.svg)
![](filled003.svg)

19 changes: 17 additions & 2 deletions docs/examples/2d/heatmaps/heatmap.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@



```julia
using Gnuplot
empty!(Gnuplot.options.init)
push!( Gnuplot.options.init, linetypes(:Set1_5, lw=1.5, ps=1.5))
function saveas(file; sx=550, sy=350, fs=0.8, term="svg")
Gnuplot.save(term="$(term) size $(sx),$(sy) fontscale $(fs)", "$(file).svg")
end;
```


<a id='image-plot'></a>

## image plot


```julia
using Gnuplot, Random
Random.seed!(1234)
Expand All @@ -10,9 +25,9 @@ matrix = randn(50,60)


```
"assets/heatmap001.svg"
"heatmap001.svg"
```


![](assets/heatmap001.svg)
![](heatmap001.svg)

File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
36 changes: 23 additions & 13 deletions docs/examples/2d/heatmaps/heatmap_cblabel.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,33 @@


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


```
"assets/heatmap004.svg"
<a id='Heatmap:-colorbar'></a>

## Heatmap: colorbar


```julia
using Random
Random.seed!(123)

test = rand(50,50)
@gp "set auto fix" "set size square" :-
@gp :- test "w image pixels notit" """set cblabel "CBTitle \\n (my unit)" """ :-
@gp :- "set cblabel offset -6.5, 10 font ',8' textcolor lt 3 rotate by 0" :-
@gp :- palette(:plasma) :-
@gp :- "set tmargin at screen 0.80"
saveas("heatmap004");
```


![](assets/heatmap004.svg)
![](heatmap004.svg)

Loading

0 comments on commit 811e061

Please sign in to comment.