octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fast scatter plots - advice sought


From: David Bateman
Subject: Re: fast scatter plots - advice sought
Date: Tue, 12 Jan 2010 02:27:31 +0100
User-agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090706)

Jaroslav Hajek wrote:
Perhaps, but performance of plotting *is* a damn good reason. A
scatter plot taking a minute is almost as good as if it didn't work at
all. Just count the people on the ML worried about plotting
performance vs. those that are worried about compatibility of
primitive representations. OK, the fltk backend will improve
performance in general, but this was one case where the lousy
performance was not a backend issue.

The progress of code seems to be

partially working -> working -> fast

Yes a trade off of compatibility for speed at the second step is a choice that can be made, if they incompatibility doesn't cause issues.


Line objects don't support colormaps and the example I gave won't work with
Jaroslav's code.. This seems a good reason "to keep" matlab compatibility to
me (ie using patch)


OK, I copied the old patch constructors back in there. Hence, your
example now works. I take it that lines don't support colormaps in
Matlab either?
Exactly, matlab doesn't support colormaps for line object either.

Though note that the mess in __go_draw_axes__ to handle the colormaps will
probably make Jaroslav's change much slower using patch objects, though
still faster for a larger number of points..


Actually, it doesn't seem to be significantly slower for the main
cases I care about (plotting lots of points in the same color).
Ok, but colormaps might be different.

However, the "filled" option does not work now:
lt-octave:1> scatter (rand (1, 20), rand (1, 20), "filled")
error: invalid color specification: flat
error: invalid value for color property "markerfacecolor" (value = flat)
error: called from:
error:   /home/highegg/devel/octave/scripts/plot/private/__scatter__.m
at line 154, column 11
error:   /home/highegg/devel/octave/scripts/plot/scatter.m at line 70, column 7

and the result was the same even prior to all these patches. Can
anyone give me a clue how to correct this?
Even line objects didn't support filling till I added the patch

http://hg.savannah.gnu.org/hgweb/octave/rev/3b7e644bb46d

following the thread

http://old.nabble.com/Plot-Bug%3A-'markerfacecolor'-does-not-work-to25562839.html

though I only treated line and surface objects. The reason I didn't treat patch object was that the patch code didn't use the do_linestyle_command function and untangling the mess seemed to be more effort than it was worth. Something like the attached should add the same functionality to the patch objects, but I can't test at the moment as I haven't rebuilt for a while and I'm in the middle of a build. It doesn't untangle the mess but rather duplicates the functionality of the do_linestyle_command function in the patch objects.

D.


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
@@ -797,75 +797,184 @@
               if (isfield (obj, "marker"))
                 switch (obj.marker)
                   case "+"
-                    pt = "pt 1";
+                    pt = pt2 = "pt 1";
                   case "o"
                     pt = "pt 6";
+                     pt2 = "pt 7";
                   case "*"
-                    pt = "pt 3";
+                    pt = pt2 = "pt 3";
                   case "."
-                    pt = "pt 0";
+                    pt = pt2 = "pt 0";
                   case "x"
-                    pt = "pt 2";
+                    pt = pt2 = "pt 2";
                   case {"square", "s"}
-                    pt = "pt 5";
+                    pt = "pt 4";
+                    pt2 = "pt 5";
                   case {"diamond", "d"}
                     pt = "pt 13";
+                    pt2 = "pt 14";
                   case "^"
-                    pt = "pt 9";
+                    pt = "pt 8";
+                    pt2 = "pt 9";
                   case "v"
-                    pt = "pt 11";
+                    pt = "pt 10";
+                    pt2 = "pt 11";
                   case ">"
+                    ## FIXME missing point type 
                     pt = "pt 8";
+                    pt2 = "pt 9";
                   case "<"
+                    ## FIXME missing point type 
                     pt = "pt 10";
+                    pt2 = "pt 11";
                   case {"pentagram", "p"}
-                    pt = "pt 4";
+                    ## FIXME missing point type 
+                    pt = pt2 = "pt 3";
                   case {"hexagram", "h"}
-                    pt = "pt 12";
+                    pt = pt2 = "pt 3";
                   case "none"
-                    pt = "";
+                    pt = pt2 = "";
                   otherwise
-                    pt = "";
+                    pt = pt2 = "";
                 endswitch
               endif
             else
               pt = "";
             endif
 
-            style = "lines";
-            if (isempty (lt))
-              if (! isempty (pt))
-                style = "points";
-              endif
-            elseif (! isempty (pt))
-              style = "linespoints";
-            endif
-
-            if (isfield (obj, "markersize"))
-              if (length (mdat) == nc)
-                m = mdat(i);
-              else
-                m = mdat;
-              endif
-              if (! strcmpi (style, "lines"))
-                ps = sprintf("pointsize %f", m);
-              else
-                ps = "";
-              endif
-            else
-              ps = "";
-            endif
-
             if (mono)
               colorspec = "";
             else
               colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
                                    round (255*color));
             endif
-            withclause{data_idx} = sprintf ("with %s %s %s %s %s %s",
-                                            style, lw, pt, lt, ps, 
-                                            colorspec);
 
+             sidx = 1;
+             if (isempty (lt))
+               style {sidx} = "";
+             else
+               style {sidx} = "lines";
+             endif
+             tmpwith = {};
+
+             facesame = true;
+             if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor") 
+                && !strncmp (obj.markerfacecolor, "none", 4))
+               if (strncmp (obj.markerfacecolor, "auto", 4)
+                  || ! isnumeric (obj.markerfacecolor) 
+                  || (isnumeric (obj.markerfacecolor) 
+                      && isequal (color, obj.markerfacecolor)))
+                style {sidx} = strcat (style{sidx}, "points");
+                if (isfield (obj, "markersize"))
+                  if (length (mdat) == nc)
+                    m = mdat(i);
+                  else
+                    m = mdat;
+                  endif
+                  ps = sprintf("pointsize %f", m / 3);
+                 else
+                   ps = "";
+                endif
+
+                tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
+                                         style{sidx}, lw, pt2, lt, ps, 
+                                         colorspec);
+               else
+                facesame = false;
+                if (! isempty (style {sidx}))  
+                  tmpwith{sidx} = sprintf ("with %s %s %s %s",
+                                           style{sidx}, lw, lt, 
+                                           colorspec);
+                  sidx ++;
+                endif
+                if (isnumeric (obj.markerfacecolor) && ! mono)
+                  colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
+                                       round (255*obj.markerfacecolor));
+                endif
+                style {sidx} = "points";
+                if (isfield (obj, "markersize"))
+                  if (length (mdat) == nc)
+                    m = mdat(i);
+                  else
+                    m = mdat;
+                  endif
+                  ps = sprintf("pointsize %f", m / 3);
+                 else
+                   ps = "";
+                endif
+                tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
+                                         style{sidx}, lw, pt2, lt, ps, 
+                                         colorspec);
+               endif
+             endif
+
+             if (isfield (obj, "markeredgecolor") 
+                && !strncmp (obj.markeredgecolor, "none", 4))
+               if (facesame && (strncmp (obj.markeredgecolor, "auto", 4)
+                               || ! isnumeric (obj.markeredgecolor) 
+                               || (isnumeric (obj.markeredgecolor) 
+                                   && isequal (color, obj.markeredgecolor))))
+                if (! isequal (pt, pt2) && sidx == 1 
+                     && ((length (style {sidx}) == 5 
+                         && strncmp (style {sidx}, "lines", 5)) 
+                         || isempty (style {sidx})))
+                  style {sidx} = strcat (style{sidx}, "points");
+                  if (isfield (obj, "markersize"))
+                    if (length (mdat) == nc)
+                      m = mdat(i);
+                    else
+                      m = mdat;
+                    endif
+                    ps = sprintf("pointsize %f", m / 3);
+                   else
+                     ps = "";
+                  endif
+                  tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
+                                           style{sidx}, lw, pt, lt, ps, 
+                                           colorspec);
+                endif
+               else
+                if (!isempty (style {sidx}))   
+                   if (isempty (tmpwith{sidx}))
+                    tmpwith{sidx} = sprintf ("with %s %s %s %s",
+                                             style{sidx}, lw, lt, 
+                                             colorspec);
+                   endif
+                  sidx ++;
+                endif
+                if (! mono)
+                  if (strncmp (obj.markeredgecolor, "auto", 4))
+                    colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
+                                         round (255*color));
+                  elseif (isnumeric (obj.markeredgecolor) && ! mono)
+                    colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
+                                         round (255*obj.markeredgecolor));
+                  endif
+                endif
+                style {sidx} = "points";
+                if (isfield (obj, "markersize"))
+                  if (length (mdat) == nc)
+                    m = mdat(i);
+                  else
+                    m = mdat;
+                  endif
+                  ps = sprintf("pointsize %f", m / 3);
+                 else
+                   ps = "";
+                endif
+                tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
+                                         style{sidx}, lw, pt, lt, ps, 
+                                         colorspec);
+               endif
+             endif
+
+             if (isempty (tmpwith))
+               withclause{data_idx} = sprintf ("with %s %s %s %s %s",
+                                               style{1}, lw, pt, lt, 
+                                               colorspec);
+             else
+              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)], ...
@@ -882,6 +991,29 @@
               endif
               usingclause{data_idx} = sprintf ("record=%d using ($1):($2)", 
columns (data{data_idx}));
             endif
+
+            if (length (tmpwith) > 1)
+              data_idx++;
+              is_image_data(data_idx) = is_image_data(data_idx - 1); 
+              parametric(data_idx) = parametric(data_idx - 1);
+              have_cdata(data_idx) = have_cdata(data_idx - 1);
+              have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
+              titlespec{data_idx} = "title \"\"";
+              usingclause{data_idx} = usingclause{data_idx - 1};
+              data{data_idx} = data{data_idx - 1};
+              withclause{data_idx} = tmpwith{2};
+            endif
+            if (length (tmpwith) > 2)
+              data_idx++;
+              is_image_data(data_idx) = is_image_data(data_idx - 1); 
+              parametric(data_idx) = parametric(data_idx - 1);
+              have_cdata(data_idx) = have_cdata(data_idx - 1);
+              have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
+              titlespec{data_idx} = "title \"\"";
+              usingclause{data_idx} = usingclause{data_idx - 1};
+              data{data_idx} = data{data_idx - 1};
+              withclause{data_idx} = tmpwith{3};
+            endif
           endif
         endfor
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]