[26473] | 1 | import ColorSchemes.jet
|
---|
[26472] | 2 | using GLMakie
|
---|
[26522] | 3 | using .ISSM
|
---|
[26472] | 4 |
|
---|
[26522] | 5 | function plotmodel(md::ISSM.model,data::Vector)
|
---|
[26472] | 6 |
|
---|
| 7 | vertexcolor = :black
|
---|
| 8 | facetcolor = :blue
|
---|
| 9 | showvertices = true
|
---|
| 10 | showfacets = true
|
---|
| 11 |
|
---|
[26473] | 12 | if data isa AbstractVector
|
---|
[26472] | 13 |
|
---|
[26473] | 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
|
---|
[26492] | 30 | #Colorbar(fig[1, 2], h, width=25)
|
---|
[26473] | 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 |
|
---|
[26472] | 40 | if showvertices
|
---|
| 41 | Makie.scatter!( [md.mesh.x md.mesh.y], markersize = 4, color = vertexcolor)
|
---|
| 42 | end
|
---|
| 43 |
|
---|
[26473] | 44 | return fig
|
---|
[26472] | 45 | end
|
---|