Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,22 @@ save
default_plotter
default_plotter!
plottertype
PlotterType
PythonPlotType
PyPlotType
MakieType
UnionPythonPlotterType
UnionMakieType
PlotsType
PlutoVistaType
VTKViewType
MeshCatType
UnicodePlotsType
```

### Deprecated Plottertypes
```@docs
MakieType
```


## Plotting grids
Expand Down
2 changes: 2 additions & 0 deletions docs/src/privapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ isplutovista
isplots
ismakie
isvtkview
ismeshcat
isunicodeplots
```

## Makie
Expand Down
12 changes: 6 additions & 6 deletions examples/plotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ end
# ### Animation of function on 1D grid
function anim_func1d(; Plotter = default_plotter(), kwargs...)
step = 0.01
if ismakie(Plotter)
if plottertype(Plotter) <: UnionMakieType
step = 0.0001
end
g = grid1d(; n = 50)
Expand All @@ -214,7 +214,7 @@ end
# ### Animation of function on 2D grid
function anim_func2d(; Plotter = default_plotter(), kwargs...)
step = 0.05
if ismakie(Plotter)
if plottertype(Plotter) <: UnionMakieType
step = 0.005
end
g = grid2d(; n = 30)
Expand All @@ -229,7 +229,7 @@ end
# ### Animation of function on 3D grid
function anim_func3d(; Plotter = default_plotter(), kwargs...)
step = 0.05
if ismakie(Plotter)
if plottertype(Plotter) <: UnionMakieType
step = 0.005
end
g = grid3d(; n = 15)
Expand Down Expand Up @@ -447,9 +447,9 @@ function plotting_custom(; Plotter = default_plotter(), kwargs...)
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)
plottertype(Plotter) <: UnionMakieType && Plotter.scatter!(ax, rand(10), rand(10), fill(0.1, 10); color = :blue, markersize = 20)
plottertype(Plotter) <: PyPlotType && ax.scatter(rand(10), rand(10); s = 500)
plottertype(Plotter) <: PlotsType && Plotter.scatter!(ax, rand(10), rand(10); color = :blue, markersize = 10, label = nothing)
end
return reveal(vis)
end
Expand Down
34 changes: 17 additions & 17 deletions ext/GridVisualizeMakieExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using Interpolations: linear_interpolation
using IntervalSets

import GridVisualize: initialize!, save, reveal, gridplot!, scalarplot!, vectorplot!, streamplot!, customplot!, movie, plot_triangulateio!
using GridVisualize: MakieType, GridVisualizer, SubVisualizer
using GridVisualize: UnionMakieType, GridVisualizer, SubVisualizer
using GridVisualize: isolevels, cellcolors, num_cellcolors, vectorsample, quiverdata, regionmesh, bfacesegments

using ExtendableGrids
Expand All @@ -24,7 +24,7 @@ using Observables

include("flippablelayout.jl")

function initialize!(p::GridVisualizer, ::Type{MakieType})
function initialize!(p::GridVisualizer, ::Type{MakieType}) where {MakieType <: UnionMakieType}
XMakie = p.context[:Plotter]

# Prepare flippable layout
Expand Down Expand Up @@ -57,7 +57,7 @@ end
add_scene!(ctx, ax) = ctx[:flayout][ctx[:subplot]...] = ax

# Revealing the visualizer just returns the figure
function reveal(p::GridVisualizer, ::Type{MakieType})
function reveal(p::GridVisualizer, ::Type{MakieType}) where {MakieType <: UnionMakieType}
XMakie = p.context[:Plotter]
layout = p.context[:layout]
# For 1D plots the legend should be rendered only once,
Expand All @@ -84,18 +84,18 @@ function reveal(p::GridVisualizer, ::Type{MakieType})
end
end

function reveal(ctx::SubVisualizer, TP::Type{MakieType})
function reveal(ctx::SubVisualizer, TP::Type{MakieType}) where {MakieType <: UnionMakieType}
FlippableLayout.yieldwait(ctx[:flayout])
if ctx[:show] || ctx[:reveal]
return reveal(ctx[:GridVisualizer], TP)
end
return nothing
end

function save(fname, p::GridVisualizer, ::Type{MakieType})
function save(fname, p::GridVisualizer, ::Type{MakieType}) where {MakieType <: UnionMakieType}
return p.context[:Plotter].save(fname, p.context[:figure])
end
function save(fname, scene, XMakie, ::Type{MakieType})
function save(fname, scene, XMakie, ::Type{MakieType}) where {MakieType <: UnionMakieType}
return isnothing(scene) ? nothing : XMakie.save(fname, scene)
end

Expand All @@ -107,7 +107,7 @@ function movie(
file = nothing,
format = "gif",
kwargs...,
)
) where {MakieType <: UnionMakieType}
Plotter = vis.context[:Plotter]
if !isnothing(file)
format = lstrip(splitext(file)[2], '.')
Expand Down Expand Up @@ -276,7 +276,7 @@ function scenecorners1d(grid, gridscale)
end

# 1D version
function gridplot!(ctx, TP::Type{MakieType}, ::Type{Val{1}}, grid)
function gridplot!(ctx, TP::Type{MakieType}, ::Type{Val{1}}, grid) where {MakieType <: UnionMakieType}
XMakie = ctx[:Plotter]
nregions = num_cellregions(grid)
nbregions = num_bfaceregions(grid)
Expand Down Expand Up @@ -354,7 +354,7 @@ end
########################################################################
# 1D function

function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{1}}, grids, parentgrid, funcs)
function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{1}}, grids, parentgrid, funcs) where {MakieType <: UnionMakieType}
XMakie = ctx[:Plotter]

nfuncs = length(funcs)
Expand Down Expand Up @@ -616,7 +616,7 @@ function set_plot_data!(ctx, key, data)
return haskey(ctx, key) ? ctx[key][] = data : ctx[key] = Observable(data)
end

function gridplot!(ctx, TP::Type{MakieType}, ::Type{Val{2}}, grid)
function gridplot!(ctx, TP::Type{MakieType}, ::Type{Val{2}}, grid) where {MakieType <: UnionMakieType}
XMakie = ctx[:Plotter]

nregions = num_cellcolors(grid, ctx[:cellcoloring])
Expand Down Expand Up @@ -731,7 +731,7 @@ function makescene2d(ctx, key)
end

# 2D function
function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{2}}, grids, parentgrid, funcs)
function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{2}}, grids, parentgrid, funcs) where {MakieType <: UnionMakieType}
XMakie = ctx[:Plotter]
gridscale = ctx[:gridscale]

Expand Down Expand Up @@ -869,7 +869,7 @@ function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{2}}, grids, parentgrid
end

# 2D vector
function vectorplot!(ctx, TP::Type{MakieType}, ::Type{Val{2}}, grid, func)
function vectorplot!(ctx, TP::Type{MakieType}, ::Type{Val{2}}, grid, func) where {MakieType <: UnionMakieType}
XMakie = ctx[:Plotter]

rc, rv = vectorsample(grid, func; gridscale = ctx[:gridscale], rasterpoints = ctx[:rasterpoints], offset = ctx[:offset])
Expand Down Expand Up @@ -914,7 +914,7 @@ function vectorplot!(ctx, TP::Type{MakieType}, ::Type{Val{2}}, grid, func)
return reveal(ctx, TP)
end

function streamplot!(ctx, TP::Type{MakieType}, ::Type{Val{2}}, grid, func)
function streamplot!(ctx, TP::Type{MakieType}, ::Type{Val{2}}, grid, func) where {MakieType <: UnionMakieType}
XMakie = ctx[:Plotter]

rc, rv = vectorsample(
Expand Down Expand Up @@ -1080,7 +1080,7 @@ pgup/pgdown: coarse control control value
h: print this message
"""

function gridplot!(ctx, TP::Type{MakieType}, ::Type{Val{3}}, grid)
function gridplot!(ctx, TP::Type{MakieType}, ::Type{Val{3}}, grid) where {MakieType <: UnionMakieType}
function make_mesh(pts, fcs)
if pkgversion(GeometryBasics) < v"0.5"
return GeometryBasics.Mesh(meta(pts; normals = normals(pts, fcs)), fcs)
Expand Down Expand Up @@ -1273,7 +1273,7 @@ function gridplot!(ctx, TP::Type{MakieType}, ::Type{Val{3}}, grid)
end

# 3d function
function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{3}}, grids, parentgrid, funcs)
function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{3}}, grids, parentgrid, funcs) where {MakieType <: UnionMakieType}
levels, crange, colorbarticks = isolevels(ctx, funcs)
ctx[:crange] = crange
ctx[:colorbarticks] = colorbarticks
Expand Down Expand Up @@ -1514,7 +1514,7 @@ end
# Thanks! lines(x, y, axis = (targetlimits = lims,)) indeed makes the limits update.^
# I found that autolimits!(axis) gave good results, even better than me manually computing limits!

function customplot!(ctx, TP::Type{MakieType}, func)
function customplot!(ctx, TP::Type{MakieType}, func) where {MakieType <: UnionMakieType}
XMakie = ctx[:Plotter]
if !haskey(ctx, :scene)
ctx[:scene] = XMakie.Axis(
Expand All @@ -1539,7 +1539,7 @@ function plot_triangulateio!(
voronoi = nothing,
circumcircles = false,
kwargs...
)
) where {MakieType <: UnionMakieType}
XMakie = ctx[:Plotter]

function frgb(Plotter, i, max; pastel = false)
Expand Down
4 changes: 2 additions & 2 deletions src/GridVisualize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ include("dispatch.jl")
include("common.jl")
include("pycommon.jl")
include("slice_plots.jl")
include("deprecated.jl")

export scalarplot, scalarplot!
export gridplot, gridplot!
Expand All @@ -31,11 +32,10 @@ export customplot, customplot!
export quiverdata, vectorsample
export plot_triangulateio, plot_triangulateio!
export save, reveal
export isplots, isvtkview, ispyplot, ispythonplot, ismakie, isplutovista
export GridVisualizer, SubVisualizer
export plottertype, available_kwargs
export default_plotter!, default_plotter
export PyPlotType, PythonPlotType, MakieType, PlotsType, VTKViewType, PlutoVistaType, MeshCatType
export PlotterType, PyPlotType, PythonPlotType, UnionPythonPlotterType, UnionMakieType, PlotsType, VTKViewType, PlutoVistaType, MeshCatType, UnicodePlotsType
export movie

end
123 changes: 123 additions & 0 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
"""
$(SIGNATURES)

Heuristically check if Plotter is VTKView (deprecated)
"""
function isvtkview(Plotter)
Base.depwarn(
"The function `isvtkview(Plotter)` will be deprecated in a future release. "
* "Please use `plottertype(Plotter) <: VTKViewType` instead.",
:isvtkview
)
return plottertype(Plotter) <: VTKViewType
end

"""
$(SIGNATURES)

Heuristically check if Plotter is PyPlot (deprecated)
"""
function ispyplot(Plotter)
Base.depwarn(
"The function `ispyplot(Plotter)` will be deprecated in a future release. "
* "Please use `plottertype(Plotter) <: PyPlotType` instead.",
:ispyplot
)
return plottertype(Plotter) <: PyPlotType
end

"""
$(SIGNATURES)

Heuristically check if Plotter is PythonPlot (deprecated)
"""
function ispythonplot(Plotter)
Base.depwarn(
"The function `ispythonplot(Plotter)` will be deprecated in a future release. "
* "Please use `plottertype(Plotter) <: PythonPlotType` instead.",
:is
)
return plottertype(Plotter) <: PythonPlotType
end

"""
$(SIGNATURES)

Heuristically check if Plotter is Plots (deprecated)
"""
function isplots(Plotter)
Base.depwarn(
"The function `isplots(Plotter)` will be deprecated in a future release. "
* "Please use `plottertype(Plotter) <: PlotsType` instead.",
:isplots
)
return plottertype(Plotter) <: PlotsType
end

"""
$(SIGNATURES)

Heuristically check if Plotter is Makie/WGLMakie (deprecated)
"""
function ismakie(Plotter)
Base.depwarn(
"The function `is(Plotter)` will be deprecated in a future release. "
* "Please use `plottertype(Plotter) <: UnionMakieType` instead.",
:ismakie
)
return plottertype(Plotter) <: UnionMakieType
end

"""
$(SIGNATURES)

Heuristically check if Plotter is MeshCat (deprecated)
"""
function ismeshcat(Plotter)
Base.depwarn(
"The function `ismeshcat(Plotter)` will be deprecated in a future release. "
* "Please use `plottertype(Plotter) <: MeshCatType` instead.",
:ismeshcat
)
return plottertype(Plotter) <: MeshCatType
end

"""
$(SIGNATURES)

Heuristically check if Plotter is PlutoVista (deprecated)
"""
function isplutovista(Plotter)
Base.depwarn(
"The function `isplutovista(Plotter)` will be deprecated in a future release. "
* "Please use `plottertype(Plotter) <: PlutoVistaType` instead.",
:isplutovista
)
return plottertype(Plotter) <: PlutoVistaType
end

"""
$(SIGNATURES)

Heuristically check if Plotter is UnicodePlots (deprecated)
"""
function isunicodeplots(Plotter)
Base.depwarn(
"The function `isunicodeplots(Plotter)` will be deprecated in a future release. "
* "Please use `plottertype(Plotter) <: UnicodePlotsType` instead.",
:is
)
return plottertype(Plotter) <: UnicodePlotsType
end

"""
const MakieType = UnionMakieType

Deprecated parent type for dispatch on Makie plotters.
"""
const MakieType = UnionMakieType
Base.@deprecate_binding MakieType UnionMakieType


export isvtkview, ispyplot, ispythonplot, isplots, ismakie, ismeshcat, isplutovista, isunicodeplots
export MakieType
Loading
Loading