Skip to content

Commit 89e8f0d

Browse files
authored
Merge pull request #65 from WIAS-PDELib/feature/slice-line-plot
Add high level methods for sliceplot and lineplot
2 parents 2962c4d + 3e8d27c commit 89e8f0d

13 files changed

+666
-77
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## [1.11.0] - 2025-03-04
4+
5+
### Added
6+
7+
- New key word argument `slice` for `scalarplot` to extract a `dim-1` scalar plot along a slice definition.
8+
The slice can be provided as an expression `slice = :(x + 2y - 4)` constrained by zero, or as a pair `slice = :x => 3`
9+
to fix a certain value of one axis.
10+
311
## [1.10.0] - 2025-01-20
412

513
### Added

Project.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "GridVisualize"
22
uuid = "5eed8a63-0fb0-45eb-886d-8d5a387d12b8"
33
authors = ["Juergen Fuhrmann <[email protected]>", "Patrick Jaap <[email protected]>"]
4-
version = "1.10.0"
4+
version = "1.11.0"
55

66
[deps]
77
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
@@ -39,7 +39,7 @@ ElasticArrays = "1"
3939
ExtendableGrids = "1.10"
4040
GLMakie = "0.9, 0.10, 0.11"
4141
GeometryBasics = "0.4.1, 0.5"
42-
GridVisualizeTools = "2"
42+
GridVisualizeTools = "3"
4343
HypertextLiteral = "0.9"
4444
Interpolations = "0.14, 0.15"
4545
IntervalSets = "0.7"

docs/makeplots.jl

+12
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ function makeplots(picdir; Plotter = GLMakie, extension = "png")
2424
@test isfile(fname)
2525
println("func3d")
2626

27+
p = plotting_slice3d(; Plotter = Plotter)
28+
fname = joinpath(picdir, "plotting_slice3d." * extension)
29+
save(fname, p; Plotter = Plotter)
30+
@test isfile(fname)
31+
println("slice3d")
32+
33+
p = plotting_line2d(; Plotter = Plotter)
34+
fname = joinpath(picdir, "plotting_line2d." * extension)
35+
save(fname, p; Plotter = Plotter)
36+
@test isfile(fname)
37+
println("line2d")
38+
2739
fname = joinpath(picdir, "plotting_jfunc1d." * "gif")
2840
p = plotting_jfunc1d(; Plotter = Plotter, filename = fname)
2941
@test isfile(fname)

docs/src/privapi.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Modules = [GridVisualize]
77
Private = true
88
Public = false
9-
Pages = ["dispatch.jl","common.jl"]
9+
Pages = ["dispatch.jl","common.jl","slice_plots.jl"]
1010
```
1111

1212
```@docs
@@ -43,7 +43,7 @@ FlippableLayout
4343
Modules = [GridVisualize]
4444
Private = true
4545
Public = false
46-
Pages = ["plots.jl"]
46+
Pages = [joinpath("src","plots.jl")] # https://github.com/JuliaDocs/Documenter.jl/issues/2639
4747
```
4848

4949
## VTKView
@@ -53,3 +53,8 @@ Private = true
5353
Public = false
5454
Pages = ["vtkview.jl"]
5555
```
56+
57+
## Internals
58+
```@docs
59+
GridVisualize.ImplEvalSlice
60+
```

examples/plotting.jl

+53
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,59 @@ function plotting_func3d(;
110110
end
111111
# ![](plotting_func3d.svg)
112112

113+
# ## d-1 dim slice in d-dim data
114+
# ### 2D slice of a 3D grid
115+
#
116+
# You can plot a 2D slice of a function defined on a
117+
# 3D grid by providing a `slice` key word argument which
118+
# describes a plane equation of a fixed value to one axis.
119+
#
120+
# The example shows a plot for a fixed axis y = 0.5.
121+
# Note that labeling the other axes may be useful
122+
function plotting_slice3d(;
123+
Plotter = default_plotter(),
124+
slice = :y => 0.5,
125+
xlabel = "x",
126+
ylabel = "z",
127+
kwargs...,
128+
)
129+
g, f = func3d()
130+
return scalarplot(g, f; Plotter, slice, xlabel, ylabel, kwargs...)
131+
end
132+
# ![](plotting_slice3d.svg)
133+
134+
135+
# ### 1D line of a 2D grid
136+
#
137+
# You can plot a 1D line of a function defined on a
138+
# 2D grid by providing a `slice` key word argument which
139+
# describes a line equation of a fixed value to one axis.
140+
#
141+
# The example shows a plot along the diagonal x + y - 1 = 0
142+
# Note that you should provide meaningful axes labels
143+
function plotting_line2d(;
144+
Plotter = default_plotter(),
145+
slice = :(x + y - 1),
146+
xlabel = "line",
147+
ylabel = "value",
148+
kwargs...,
149+
)
150+
g, f = func2d()
151+
return scalarplot(g, f; Plotter, slice, xlabel, ylabel, kwargs...)
152+
end
153+
# ![](plotting_line2d.svg)
154+
155+
156+
#
157+
# Plotting a function then goes as follows:
158+
# `xplane`, `yplane` and `zplane` now define cut planes where
159+
# the function projection is plotted as a heatmap.
160+
# The additional `flevel` keyword argument allows
161+
# to control an isolevel.
162+
#
163+
# For Makie and VTKView, the cutplane values and the flevel can be controlled interactively.
164+
165+
113166
# ## Vector and stream plots
114167
# ### 2D vector
115168
function vec2d(; n = 20)

0 commit comments

Comments
 (0)