add_ellipse_variable.m 865 Bytes
Newer Older
1
function hts = add_ellipse_variable( obj, values, cmap, ax )
2
3
4
5
%ADD_ELLIPSE_VARIABLE Plots the ellipses, colored by the specified values.
    
    epicells = obj.epicells;
    n_objects = numel( epicells );
6
    hts = NaN( 2 * n_objects, 1 );
7
8
9
10

    minv = min( values );
    maxv = max( values );

11
    colors = colormap( cmap );
12
13
    
    if n_objects > 1000, lw = 1; else, lw = 2; end
14
15
16
17
18

    idx = @(v) 1 + round( (v - minv)/(maxv - minv)  * ( size( colors, 1 ) - 1 ) );
    for i = 1 :  n_objects

        o = epicells( i );
19
20
        h1 =  o.plot_ellipse_3d( 23, ax );
        h2 =  o.plot_ellipse_3d( 3, ax );
21

22
23
        hts( 2 * i - 1 ) =  h1;
        hts( 2 * i ) =  h1;
24
25
        val = values( i );
        j = idx( val );
26
        set( [ h1 h2 ], ...
27
            'Color', colors( j, : ), ...
28
            'LineWidth', lw )
29
    end
30
    set( ax, 'CLim', [ minv maxv ] )
31
end