Changeset 26473


Ignore:
Timestamp:
10/05/21 18:44:52 (3 years ago)
Author:
Mathieu Morlighem
Message:

CHG: minor

Location:
issm/trunk-jpl/src/jl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/jl/exp.jl

    r26472 r26473  
     1#for exptool, look into this http://juliaplots.org/MakieReferenceImages/gallery//mouse_picking/index.html
    12
    23#exp object definition, constructor, and disp
  • issm/trunk-jpl/src/jl/plotmodel.jl

    r26472 r26473  
    1 
    2 #import ColorSchemes.leonardo
    3 #include("issm.jl")
     1import ColorSchemes.jet
    42
    53using GLMakie
    64
    7 function plotmodel(md::model)
     5function plotmodel(md::model,data)
    86
    9         elementcolor = :yellow
    107        vertexcolor  = :black
    118        facetcolor   = :blue
     
    1310        showfacets   = true
    1411
    15         scene = Makie.mesh( [md.mesh.x md.mesh.y], md.mesh.elements, shading = false, color = elementcolor)
     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
    1639
    1740        if showvertices
     
    1942        end
    2043
    21 
    22         return scene
     44        return fig
    2345end
Note: See TracChangeset for help on using the changeset viewer.