diff --git a/docs/make.jl b/docs/make.jl index e4e3f9f..d57419f 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,7 +1,7 @@ using Documenter, GridVisualizeTools, ColorTypes function mkdocs() - DocMeta.setdocmeta!(GridVisualizeTools, :DocTestSetup, :(using GridVisualizeTools, ColorTypes); recursive=true) + DocMeta.setdocmeta!(GridVisualizeTools, :DocTestSetup, :(using GridVisualizeTools, ColorTypes, Colors); recursive=true) makedocs(sitename="GridVisualizeTools.jl", modules = [GridVisualizeTools], clean = false, diff --git a/docs/src/index.md b/docs/src/index.md index 8e27af8..02e2667 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -12,6 +12,7 @@ $(read("../../README.md",String)) region_cmap ``` ```@example +using GridVisualizeTools # hide region_cmap(5) ``` @@ -20,6 +21,7 @@ region_cmap(5) bregion_cmap ``` ```@example +using GridVisualizeTools # hide bregion_cmap(5) ``` @@ -66,13 +68,13 @@ marching_tetrahedra markerpoints ``` -## Makeplanes +## Planes & isolevels ```@docs makeplanes ``` ```jldoctest -using GridVisualizeTools # hide +using GridVisualizeTools makeplanes([0.,0,0], [1.,1,1], [0.5], [],[]) # output 1-element Vector{Vector{Float64}}: @@ -80,10 +82,36 @@ makeplanes([0.,0,0], [1.,1,1], [0.5], [],[]) ``` ```jldoctest -using GridVisualizeTools # hide +using GridVisualizeTools makeplanes([0.,0,0], [1.,1,1], [0.5], [0.5],[]) # output 2-element Vector{Vector{Float64}}: [1.0, 0.0, 0.0, -0.5] [0.0, 1.0, 0.0, -0.5] ``` + + +```@docs +makeisolevels +``` + +```jldoctest +using GridVisualizeTools +makeisolevels(0:0.1:10, 1, (-1,1),3) +# output +([-1.0, 0.0, 1.0], (-1, 1), [-1.0, 0.0, 1.0]) +``` + +```jldoctest +using GridVisualizeTools +makeisolevels(0:0.1:10, 1, (1,-1),3) +# output +([0.0, 5.0, 10.0], (0.0, 10.0), [0.0, 5.0, 10.0]) +``` + +```jldoctest +using GridVisualizeTools +makeisolevels(0:0.1:10, 1, (1,-1),nothing) +# output +([0.0, 5.0, 10.0], (0.0, 10.0), [0.0, 5.0, 10.0]) +``` diff --git a/src/GridVisualizeTools.jl b/src/GridVisualizeTools.jl index 4a75dab..5442036 100644 --- a/src/GridVisualizeTools.jl +++ b/src/GridVisualizeTools.jl @@ -17,6 +17,6 @@ include("markerpoints.jl") export markerpoints include("planeslevels.jl") -export makeplanes +export makeplanes,makeisolevels end # module GridVisualizeTools diff --git a/src/planeslevels.jl b/src/planeslevels.jl index bef8768..661268c 100644 --- a/src/planeslevels.jl +++ b/src/planeslevels.jl @@ -40,3 +40,34 @@ function makeplanes(xyzmin,xyzmax,x,y,z) end planes end + +""" + $(SIGNATURES) + +Update levels, limits, colorbartics based on vector given in func. + +- if `limits[1]>limits[2]`, replace it by `extrema(func)`. +- if levels is a number, replace it with a linear range in `limits` of length levels+2 +- if colorbarticks is `nothing` replace it with levels, otherwise, if it is a number, replace it + with a linear range of corresponding length +""" +function makeisolevels(func,levels,limits, colorbarticks) + + if limits[1]>limits[2] + limits=extrema(func) + end + + if isa(levels,Number) + levels=collect(LinRange(limits[1],limits[2],levels+2)) + end + + if colorbarticks == nothing + colorbarticks = levels + elseif isa(colorbarticks,Number) + colorbarticks = collect(limits[1]:(limits[2]-limits[1])/(colorbarticks-1):limits[2]) + end + + # map(t->round(t,sigdigits=4),levels),limits,map(t->round(t,sigdigits=4),colorbarticks) + levels,limits,colorbarticks + +end