Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gridscale etc #20

Merged
merged 13 commits into from
Dec 9, 2023
18 changes: 9 additions & 9 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GridVisualize"
uuid = "5eed8a63-0fb0-45eb-886d-8d5a387d12b8"
authors = ["Juergen Fuhrmann <[email protected]>"]
version = "1.4.1"
version = "1.5.0"

[deps]
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
Expand All @@ -20,13 +20,6 @@ OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[weakdeps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PlutoVista = "646e1f28-b900-46d7-9d87-d554eb38a413"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"

[compat]
CairoMakie = "0.11.3"
ColorSchemes = "3"
Expand All @@ -36,7 +29,7 @@ ElasticArrays = "1"
ExtendableGrids = "0.9,1"
GLMakie = "0.9"
GeometryBasics = "0.4.1"
GridVisualizeTools = "0.3,1"
GridVisualizeTools = "1.1"
HypertextLiteral = "0.9"
Interpolations = "0.14, 0.15"
IntervalSets = "0.7"
Expand All @@ -56,3 +49,10 @@ GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PlutoVista = "646e1f28-b900-46d7-9d87-d554eb38a413"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"

[weakdeps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PlutoVista = "646e1f28-b900-46d7-9d87-d554eb38a413"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
9 changes: 8 additions & 1 deletion docs/makeplots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ function makeplots(picdir; Plotter = GLMakie, extension = "png")
fname = joinpath(picdir, "plotting_movie." * "gif")
p = plotting_movie(; filename = fname, Plotter = Plotter)
@test isfile(fname)
println("plotting_movie")
println("movie")

p = plotting_custom(; Plotter = Plotter)
fname = joinpath(picdir, "plotting_custom." * extension)
save(fname, p; Plotter = Plotter)
@test isfile(fname)
println("custom")

true
end
11 changes: 10 additions & 1 deletion docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,19 @@ streamplot
streamplot!
```

## Custom plots
```@docs
customplot
customplot!
```

## Keyword Arguments
```@docs
available_kwargs
```


## Supporting methods
```@docs
vectorsample
quiverdata
```
31 changes: 23 additions & 8 deletions examples/plotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ end
# ![](plotting_func1d.svg)

# ### Function on 2D grid
function func2d(; n = 20)
function func2d(; n = 30)
g = grid2d(; n = n)
g, map((x, y) -> sinpi(2 * x) * sinpi(3.5 * y), g)
end
Expand Down Expand Up @@ -119,17 +119,17 @@ function vec2d(; n = 20)
map((x, y) -> cospi(2 * x) * cospi(3.5 * y), g)')
end

function plotting_vec2d(; Plotter = default_plotter(), kwargs...)
g, f = vec2d()
function plotting_vec2d(; Plotter = default_plotter(), n = 20, kwargs...)
g, f = vec2d(; n = n)
vectorplot(g, f; Plotter = Plotter, kwargs...)
end
# ![](plotting_vec2d.svg)

# ### 2D stream
# Stream plots are currently only available with PyPlot and Makie
function plotting_stream2d(; Plotter = default_plotter(), kwargs...)
g, f = vec2d()
GridVisualize.streamplot(g, f; Plotter = Plotter, spacing = 0.01, kwargs...)
function plotting_stream2d(; Plotter = default_plotter(), n = 50, kwargs...)
g, f = vec2d(; n = n)
GridVisualize.streamplot(g, f; Plotter = Plotter, rasterpoints = 100, kwargs...)
end
# ![](plotting_stream2d.svg)

Expand Down Expand Up @@ -216,8 +216,8 @@ function plotting_multiscene(; Plotter = default_plotter(), resolution = (1000,
end
# ![](plotting_multiscene.svg)

# ## Plots of functions on subgrids interfaces
# We can jointly plot functions on different subgrids whic
# ## Plots of functions on subgrids
# We can jointly plot functions on different subgrids which
# e.g. model a particle density jumping at a heterointerface
# Currently supported for PyPlot and Makie
#
Expand Down Expand Up @@ -306,3 +306,18 @@ function plotting_jfunc3d(;
end

# ![](plotting_jfunc3d.svg)

# ## Custom plots
function plotting_custom(; Plotter = default_plotter(), kwargs...)
vis = GridVisualizer(; Plotter = Plotter)
grid = grid2d()
gridplot!(vis, grid)
customplot!(vis) do ax
ismakie(Plotter) && Plotter.scatter!(ax, rand(10), rand(10), fill(0.1, 10); color = :blue, markersize = 20)
ispyplot(Plotter) && ax.scatter(rand(10), rand(10); s = 500)
isplots(Plotter) && Plotter.scatter!(ax, rand(10), rand(10); color = :blue, markersize = 10, label = nothing)
end
reveal(vis)
end

# ![](plotting_custom.svg)
Loading
Loading