help-octave
[Top][All Lists]
Advanced

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

Re: contourf and linewidth


From: David Bateman
Subject: Re: contourf and linewidth
Date: Fri, 08 Feb 2008 12:32:29 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20070914)

Marco Caliari wrote:
> Hi.
>
> Is it possible to specify the line width of the contour levels in 
> contourf? The following
>
> contourf(peaks,'LineWidth',2)
>
> does not work in Octave 3.0.0, i.e., no error but no thicker lines.
>
> Best regards,
>
>   
Try it with contour also.. No errors, but no lines :-)

The issue is that the contours are in fact patch objects and not lines
so that something like "colormap cool" will change their color. In
contourf the patches FaceColor is "flat" and in contour it is "none".
Neither __go_draw_axes__.m nor __contour__.m respected the linewidth
variable. And worse, the __contourc__ function choked on the linewidth
variable generating no lines with the contour function. See the attached
patch that should fix this issue.

D.





-- 
David Bateman                                address@hidden
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary

# HG changeset patch
# User David Bateman
# Date 1202470239 -3600
# Node ID c0ebf996bc0cfeffae0f334c4cd0094a6c56f007
# Parent  b1cfd33a364b4663d723bed877376e83e34355c4
Allow linewidth to be specified for contours

diff -r b1cfd33a364b -r c0ebf996bc0c scripts/ChangeLog
--- a/scripts/ChangeLog Wed Feb 06 10:46:10 2008 +0000
+++ b/scripts/ChangeLog Fri Feb 08 12:30:39 2008 +0100
@@ -1,3 +1,9 @@ 2008-02-01  Dave Goel  <address@hidden
+2008-02-08  David Bateman  <address@hidden
+
+       * plot/__contour__.m: Respect the graphic handle options that are
+       passed.
+       * plot/__go_draw_axes__.m: Respect the linewidth for patch objects.
+
 2008-02-01  Dave Goel  <address@hidden>
 
        * signal/arch_rnd.m: Correctly index E and Y vectors.
diff -r b1cfd33a364b -r c0ebf996bc0c scripts/plot/__contour__.m
--- a/scripts/plot/__contour__.m        Wed Feb 06 10:46:10 2008 +0000
+++ b/scripts/plot/__contour__.m        Fri Feb 08 12:30:39 2008 +0100
@@ -28,7 +28,7 @@ function [c, h] = __contour__ (varargin)
   for i = 3 : nargin
     arg = varargin {i};
     if ((ischar (arg) || iscell (arg)))
-      [linespec, valid] = __pltopt__ ("quiver", arg, false);
+      [linespec, valid] = __pltopt__ ("contour", arg, false);
       if (isempty (linespec.color))
        linespec.color = "flat";
       endif
@@ -40,15 +40,24 @@ function [c, h] = __contour__ (varargin)
     endif
   endfor
 
+  opts = {};
+  i = 3;
+  while (i < length (varargin))
+    if (ischar (varargin {i}))
+      opts{end+1} = varargin{i};
+      varargin(i) = [];
+      opts{end+1} = varargin{i};
+      varargin(i) = [];
+    else
+      i++;
+    endif
+  endwhile
+
   if (ischar (z))
     if (strcmp (z, "none"))
       z = NaN;
     elseif (strcmp (z, "base"))
-      if (nargin < 3)
-       z = varargin{1};
-      else
-       z = varargin{3};
-      endif
+      z = varargin{3};
       z = 2 * (min (z(:)) - max (z(:)));
     elseif (! strcmp (z, "level"))
       error ("unrecognized z argument");
@@ -73,15 +82,15 @@ function [c, h] = __contour__ (varargin)
     if (isnan (z))
       h = [h; patch(ax, p(1,:), p(2,:), "facecolor", "none", 
                    "edgecolor", linespec.color, "linestyle", 
-                   linespec.linestyle, "cdata", clev)];
+                   linespec.linestyle, "cdata", clev, opts{:})];
     elseif (!ischar(z))
       h = [h; patch(ax, p(1,:), p(2,:), z * ones (1, columns (p)), "facecolor",
                    "none", "edgecolor", linespec.color, 
-                   "linestyle", linespec.linestyle, "cdata", clev)];
+                   "linestyle", linespec.linestyle, "cdata", clev, opts{:})];
     else
       h = [h; patch(ax, p(1,:), p(2,:), clev * ones (1, columns (p)),
                    "facecolor", "none", "edgecolor", linespec.color, 
-                   "linestyle", linespec.linestyle, "cdata", clev)];
+                   "linestyle", linespec.linestyle, "cdata", clev, opts{:})];
     endif
     i1 += clen+1;
   endwhile
diff -r b1cfd33a364b -r c0ebf996bc0c scripts/plot/__go_draw_axes__.m
--- a/scripts/plot/__go_draw_axes__.m   Wed Feb 06 10:46:10 2008 +0000
+++ b/scripts/plot/__go_draw_axes__.m   Fri Feb 08 12:30:39 2008 +0100
@@ -694,6 +694,16 @@ function __go_draw_axes__ (h, plot_strea
               lt = "";
             endif
 
+            if (isfield (obj, "linewidth"))
+              if (have_newer_gnuplot)
+                lw = sprintf("linewidth %f", obj.linewidth);
+              else
+                lw = sprintf("lw %f", obj.linewidth);
+              endif
+            else
+              lw  = "";
+            endif
+
             if (isfield (obj, "marker"))
               if (isfield (obj, "marker"))
                 switch (obj.marker)
@@ -768,8 +778,9 @@ function __go_draw_axes__ (h, plot_strea
                 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
                                      round (255*color));
               endif
-              withclause{data_idx} = sprintf ("with %s %s %s %s %s",
-                                              style, pt, lt, ps, colorspec);
+              withclause{data_idx} = sprintf ("with %s %s %s %s %s %s",
+                                              style, lw, pt, lt, ps, 
+                                              colorspec);
             else
               if (isequal (color, [0,0,0]))
                 typ = -1;
@@ -790,8 +801,8 @@ function __go_draw_axes__ (h, plot_strea
               else
                 typ = -1;
               endif
-              withclause{data_idx} = sprintf ("with %s %s %s lt %d", 
-                                              style, pt, ps, typ);
+              withclause{data_idx} = sprintf ("with %s %s %s %s lt %d", 
+                                              style, lw, pt, ps, typ);
             endif
 
             if (nd == 3)

reply via email to

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