Skip to content

Commit

Permalink
Sync with PlutoVista, add makeisolevels
Browse files Browse the repository at this point in the history
  • Loading branch information
j-fu committed Dec 4, 2022
1 parent 2d4b24b commit 24eb44a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
34 changes: 31 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ $(read("../../README.md",String))
region_cmap
```
```@example
using GridVisualizeTools # hide
region_cmap(5)
```

Expand All @@ -20,6 +21,7 @@ region_cmap(5)
bregion_cmap
```
```@example
using GridVisualizeTools # hide
bregion_cmap(5)
```

Expand Down Expand Up @@ -66,24 +68,50 @@ 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}}:
[1.0, 0.0, 0.0, -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])
```
2 changes: 1 addition & 1 deletion src/GridVisualizeTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ include("markerpoints.jl")
export markerpoints

include("planeslevels.jl")
export makeplanes
export makeplanes,makeisolevels

end # module GridVisualizeTools
31 changes: 31 additions & 0 deletions src/planeslevels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 comments on commit 24eb44a

@j-fu
Copy link
Member Author

@j-fu j-fu commented on 24eb44a Dec 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/73459

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.0 -m "<description of version>" 24eb44a747ad5e1997cea7c8111f0270689f533a
git push origin v0.2.0

Please sign in to comment.