Plots filled rectangles
CL_plot_rects(rects, icolors [[, clip_area, rectype]])
Plots filled rectangles.
The kth rectangle is filled with the color icolors(k) which should be an integer value.
If the color index is 0 or if the rectangle is outside the clip area, the rectangle is not drawn.
The argument "rectype" defines the type of rectangle description: "r" or "xy" (default is "r").
If rectype == "r", the rectangles are defined by: [x_upper_left_corner = xmin; y_upper_left_corner = ymax; width = xmax - xmin; height = ymax - ymin]
If rectype == "xy", the rectangles are defined by: [xmin; xmax; ymin; ymax]
The function is optimized for the case where the rectangles are arranged in lines: contiguous rectangles on the same line with the same color are packed in order to reduce the number of rectangles.
Rectangles (4xN)
Color indices (1xN)
(optional) Clip region: [xmin; xmax; ymin; ymax]. Default is [-%inf; %inf; -%inf; %inf] (4x1)
(string, optional) Type of rectangle description: "r" or "xy". Default is "r" (1x1)
CNES - DCT/SB
// Example 1 rects = [[0; 1; 1; 2], [1; 2; 1; 2], [2; 3; 1; 2], [1; 2; 2; 3], [2; 6; 2; 3]]; icolors = [2, 2, 3, 5, 5]; scf(); clip_area = [0; 5; 0; 4]; CL_plot_rects(rects, icolors, clip_area=clip_area, rectype="xy"); // Example 2 n = 100; vals = linspace(-1, 1, n+1); step = (vals($) - vals(1)) / n; x = (vals(1:$-1) + vals(2:$))/2; y = x; [X, Y] = ndgrid(x, y); Z = abs(X .* Y); f = scf(); nbcols = 64; f.color_map = jetcolormap(nbcols); N = size(Z, "*"); rects = [X(:)' - step/2; Y(:)' + step/2; step * ones(1:N); step * ones(1:N)]; icolors = 1 + round(Z(:)' * (nbcols - 1)); CL_plot_rects(rects, icolors); | ![]() | ![]() |