octave-maintainers
[Top][All Lists]
Advanced

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

Re: tmp gets full when plotting many images


From: John W. Eaton
Subject: Re: tmp gets full when plotting many images
Date: Mon, 26 Mar 2007 22:21:36 -0400

I also checked in the following change to send the image data to
gnuplot via the plot_stream pipe.  It seems to work for me.  However,
I just noticed the following behavior with gnuplot 4.2 with either the
wxt or x11 terminal:

  image     ## OK
  sombrero  ## OK
  image     ## Image is displayed correctly, but colorbox is garbled.
            ## See the attached screenshot.

This also happened without my most recent changes, so I don't think it
is related to sending the image data over the plot stream pipe.  Is it
just me, or can anyone else confirm this behavior?

Thanks,

jwe


scripts/ChangeLog:

2007-03-26  John W. Eaton  <address@hidden>

        * plot/__go_draw_axes__.m: Send image data to gnuplot via plot stream.


Index: scripts/plot/__go_draw_axes__.m
===================================================================
RCS file: /cvs/octave/scripts/plot/__go_draw_axes__.m,v
retrieving revision 1.11
diff -u -u -r1.11 __go_draw_axes__.m
--- scripts/plot/__go_draw_axes__.m     27 Mar 2007 02:09:27 -0000      1.11
+++ scripts/plot/__go_draw_axes__.m     27 Mar 2007 02:19:30 -0000
@@ -225,13 +225,12 @@
     nd = 0;
     data_idx = 0;
     data = cell ();
+    is_image_data = [];
 
     xminp = yminp = zminp = realmax ();
     xmax = ymax = zmax = -realmax ();
     xmin = ymin = zmin = realmax ();
 
-    palette_set = 0;
-
     [view_cmd, view_fcn, view_zoom] = image_viewer ();
     use_gnuplot_for_images = (ischar (view_fcn)
                              && strcmp (view_fcn, "gnuplot_internal"));
@@ -261,6 +260,7 @@
          if (use_gnuplot_for_images)
 
            data_idx++;
+           is_image_data(data_idx) = true;
 
            [y_dim, x_dim] = size (img_data(:,:,1));
            if (x_dim > 1)
@@ -292,50 +292,37 @@
              ## to have a means of arbitrary projection.
            endif
 
-           ## Let the file be deleted when Octave exits or `purge_tmp_files'
-           ## is called.
-           [img_fid, img_fname] = mkstemp (fullfile (P_tmpdir, 
"gpimageXXXXXX"), 1);
            if (ndims (img_data) == 3)
-             fwrite (img_fid, permute (img_data, [3, 1, 2])(:), "float");
+             data{data_idx} = permute (img_data, [3, 1, 2])(:);
              format = "1:2:3";
              imagetype = "rgbimage";
            else
-             fwrite (img_fid, img_data(:), "float");
+             data{data_idx} = img_data(:);
              format = "1";
              imagetype = "image";
-             ## Only need to set palette once because it doesn't change
-             ## on a figure.
-             if (! palette_set)
-               palette_set = 1;
-               palette_size = rows (img_colormap);
-               fprintf (plot_stream,
-                        "set palette positive color model RGB maxcolors %i;\n",
-                        palette_size);
-               fprintf (plot_stream,
-                        "set palette file \"-\" binary record=%d using 
1:2:3:4;\n",
-                        palette_size);
-               fwrite (plot_stream, [1:palette_size; img_colormap'], 
"float32");
-             endif
+
+             palette_size = rows (img_colormap);
+             fprintf (plot_stream,
+                      "set palette positive color model RGB maxcolors %i;\n",
+                      palette_size);
+             fprintf (plot_stream,
+                      "set palette file \"-\" binary record=%d using 
1:2:3:4;\n",
+                      palette_size);
+             fwrite (plot_stream, [1:palette_size; img_colormap'], "float32");
            endif
-           fclose (img_fid);
 
-           filespec{data_idx} = img_fname;
            titlespec{data_idx} = "";
            usingclause{data_idx} = sprintf ("binary array=%dx%d scan=yx 
origin=(%g,%g) dx=%g dy=%g using %s",
                x_dim, y_dim, x_origin, y_origin, dx, dy, format);
            withclause{data_idx} = sprintf ("with %s", imagetype);
 
-           ## Data in file, set to zero for data available test to pass
-           ## below.
-           data{data_idx} = 0; 
-
          else
            ximg_data{++ximg_data_idx} = img_data;
          endif
 
        case "line"
          data_idx++;
-         filespec{data_idx} = "-";
+         is_image_data(data_idx) = false;
          if (isempty (obj.keylabel))
            titlespec{data_idx} = "title \"\"";
          else
@@ -452,8 +439,8 @@
 
        case "surface"
          data_idx++;
+         is_image_data(data_idx) = false;
          [style, typ] = do_linestyle_command (obj, data_idx, plot_stream);
-         filespec{data_idx} = "-";
          if (isempty (obj.keylabel))
            titlespec{data_idx} = "title \"\"";
          else
@@ -658,15 +645,17 @@
        fputs (plot_stream, "set ticslevel 0;\n");
        fprintf (plot_stream, "set view %g, %g;\n", rot_x, rot_z);
       endif
-      fprintf (plot_stream, "%s \"%s\" %s %s %s", plot_cmd,
-              filespec{1}, usingclause{1}, titlespec{1}, withclause{1});
+      fprintf (plot_stream, "%s \"-\" %s %s %s", plot_cmd,
+              usingclause{1}, titlespec{1}, withclause{1});
       for i = 2:data_idx
-       fprintf (plot_stream, ", \"%s\" %s %s %s",
-                filespec{i}, usingclause{i}, titlespec{i}, withclause{i});
+       fprintf (plot_stream, ", \"-\" %s %s %s",
+                usingclause{i}, titlespec{i}, withclause{i});
       endfor
       fputs (plot_stream, ";\n");
       for i = 1:data_idx
-       if (strcmp (filespec{i}, "-"))
+       if (is_image_data(i))
+         fwrite (plot_stream, data{i}, "float32");
+       else
          if (nd == 2)
            fprintf (plot_stream,
                     strcat (repmat ("%g ", 1, rows (data{i})), "\n"),

PNG image


reply via email to

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