1 | import ColorSchemes.jet
|
---|
2 | using GLMakie
|
---|
3 | using .ISSM
|
---|
4 |
|
---|
5 | function plotmodel(md::ISSM.model,data::Vector)
|
---|
6 |
|
---|
7 | vertexcolor = :black
|
---|
8 | facetcolor = :blue
|
---|
9 | showvertices = true
|
---|
10 | showfacets = true
|
---|
11 |
|
---|
12 | if data isa AbstractVector
|
---|
13 |
|
---|
14 | if length(data)==md.mesh.numberofelements
|
---|
15 | # vector of polygons
|
---|
16 | x = md.mesh.x
|
---|
17 | y = md.mesh.y
|
---|
18 | index = md.mesh.elements
|
---|
19 | ps = [Makie.GeometryBasics.Polygon([Point2(x[index[i,1]], y[index[i,1]]), Point2(x[index[i,2]], y[index[i,2]]), Point2(x[index[i,3]], y[index[i,3]])])
|
---|
20 | for i in 1:md.mesh.numberofelements]
|
---|
21 |
|
---|
22 | fig, ax, h = Makie.poly(ps, color = data, colormap = jet)
|
---|
23 |
|
---|
24 | #Add colorbar
|
---|
25 | Colorbar(fig[1, 2], limits = (minimum(data), maximum(data)), colormap = jet)
|
---|
26 | elseif length(data)==md.mesh.numberofvertices
|
---|
27 | fig, ax, h = Makie.mesh( [md.mesh.x md.mesh.y], md.mesh.elements, shading = false, color = data, colormap = jet)
|
---|
28 |
|
---|
29 | #Add colorbar
|
---|
30 | #Colorbar(fig[1, 2], h, width=25)
|
---|
31 | else
|
---|
32 | error("data of size "*string(length(data))*" not supported yet!")
|
---|
33 | end
|
---|
34 | else
|
---|
35 | # default to single color
|
---|
36 | @assert length(data)==1
|
---|
37 | fig, ax, h = Makie.mesh( [md.mesh.x md.mesh.y], md.mesh.elements, shading = false, color = data, colormap = jet)
|
---|
38 | end
|
---|
39 |
|
---|
40 | if showvertices
|
---|
41 | Makie.scatter!( [md.mesh.x md.mesh.y], markersize = 4, color = vertexcolor)
|
---|
42 | end
|
---|
43 |
|
---|
44 | return fig
|
---|
45 | end
|
---|