# HG changeset patch # User David Bateman # Date 1265051854 -3600 # Node ID 8e58c402ebb23c06998e68f2c025116ae3083c3c # Parent c022ff4a2b1420d638aae0c13f7132f0296b91a5 Accelerate colormap colored scatter plots diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,10 @@ +2010-02-01 David Bateman + + * plot/private/__scatter__.m: Treat "flat" colored patches as + a single patch. + * plot/__go_draw_axes__.m: If a patch object is flat, treat its + outline with the gnuplot "palette". + 2010-01-30 Thorsten Meyer * statistics/tests/kruskal_wallis_test.m: Replace chisquare_cdf diff --git a/scripts/plot/__go_draw_axes__.m b/scripts/plot/__go_draw_axes__.m --- a/scripts/plot/__go_draw_axes__.m +++ b/scripts/plot/__go_draw_axes__.m @@ -762,16 +762,23 @@ if (numel(ccol) == 3) color = ccol; else - r = 1 + round ((size (cmap, 1) - 1) - * (ccol - clim(1))/(clim(2) - clim(1))); - r = max (1, min (r, size (cmap, 1))); - color = cmap(r, :); + if (isscalar (ccol)) + ccol = repmat(ccol, numel (xcol), 1); + endif + color = "flat"; + have_cdata(data_idx) = true; endif elseif (strncmp (ec, "interp", 6)) - warning ("\"interp\" not supported, using 1st entry of cdata"); - r = 1 + round ((size (cmap, 1) - 1) * ccol(1)); - r = max (1, min (r, size (cmap, 1))); - color = cmap(r,:); + if (numel(ccol) == 3) + warning ("\"interp\" not supported, using 1st entry of cdata"); + color = ccol(1,:); + else + if (isscalar (ccol)) + ccol = repmat(ccol, numel (xcol), 1); + endif + color = "interp"; + have_cdata(data_idx) = true; + endif endif elseif (isnumeric (ec)) color = ec; @@ -859,8 +866,12 @@ if (mono) colorspec = ""; else - colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"", - round (255*color)); + if (ischar (color)) + colorspec = "palette"; + else + colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"", + round (255*color)); + endif endif sidx = 1; @@ -993,20 +1004,40 @@ withclause{data_idx} = tmpwith{1}; endif if (nd == 3) - if (! isnan (xcol) && ! isnan (ycol) && ! isnan (zcol)) - data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ... - [zcol; zcol(1)]]'; - else - data{data_idx} = [xcol, ycol, zcol]'; - endif - usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3)", columns (data{data_idx})); + if (ischar (color)) + if (! isnan (xcol) && ! isnan (ycol) && ! isnan (zcol)) + data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ... + [zcol; zcol(1)], [ccol; ccol(1)]]'; + else + data{data_idx} = [xcol, ycol, zcol, ccol]'; + endif + usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3):($4)", columns (data{data_idx})); + else + if (! isnan (xcol) && ! isnan (ycol) && ! isnan (zcol)) + data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ... + [zcol; zcol(1)]]'; + else + data{data_idx} = [xcol, ycol, zcol]'; + endif + usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3)", columns (data{data_idx})); + endif else - if (! isnan (xcol) && ! isnan (ycol)) - data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)]]'; - else - data{data_idx} = [xcol, ycol]'; - endif - usingclause{data_idx} = sprintf ("record=%d using ($1):($2)", columns (data{data_idx})); + if (ischar (color)) + if (! isnan (xcol) && ! isnan (ycol)) + data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ... + [ccol; ccol(1)]]'; + else + data{data_idx} = [xcol, ycol, ccol]'; + endif + usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3)", columns (data{data_idx})); + else + if (! isnan (xcol) && ! isnan (ycol)) + data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)]]'; + else + data{data_idx} = [xcol, ycol]'; + endif + usingclause{data_idx} = sprintf ("record=%d using ($1):($2)", columns (data{data_idx})); + endif endif if (length (tmpwith) > 1) diff --git a/scripts/plot/private/__scatter__.m b/scripts/plot/private/__scatter__.m --- a/scripts/plot/private/__scatter__.m +++ b/scripts/plot/private/__scatter__.m @@ -185,6 +185,8 @@ if (ischar (c) || rows (c) == 1) h = render_size_color (hg, vert, s, c, marker, filled, false); + elseif (columns (c) == 1) + h = render_size_color (hg, vert, s, c, marker, filled, true); else [cc, idx] = unique_idx (c, "rows"); if (isscalar (s)) @@ -199,7 +201,6 @@ endfor endif endif - endif if (! ischar (c) && rows (c) > 1)