contourf and linewidth

View: New views
5 Messages — Rating Filter:   Alert me  

contourf and linewidth

by Marco Caliari-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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,

Marco
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: contourf and linewidth

by David Bateman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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                                David.Bateman@...
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  <deego3@...
+2008-02-08  David Bateman  <dbateman@...?
+
+ * 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  <deego3@...>
 
  * 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)

_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: contourf and linewidth

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On  8-Feb-2008, David Bateman wrote:

| 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.

I applied this changeset to my archive.

Thanks,

jwe
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: contourf and linewidth

by JJonasson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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.


Hi

I also have a problem with the linewidth for contour, so I was happy to see that someone had a solution to the problem. But what am I supposed to do with this patch? How can I get it to work?

/jonas

Re: contourf and linewidth

by dbateman3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

JJonasson wrote:

>
> 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.
>
>
> Hi
>
> I also have a problem with the linewidth for contour, so I was happy to see
> that someone had a solution to the problem. But what am I supposed to do
> with this patch? How can I get it to work?
>
> /jonas
>


It appears that this patch was only applied to the 3.1 tree, though
perhaps it should also be applied to the 3.0.x tree, even though
arguably its a new feature, and 3.0.x should only have bug fixes. In any
case to get the changeset to work for you what I'd suggest you do is the
 following

octave
which contour
quit

Note the directory where the contour function is found. It's be
something like

<prefix>/3.0.1/m/plot/contour.m

Now save the changeset somewhere like /tmp/changeset, then do

cd <prefix>/3.0.1/m
cat /tmp/changeset | patch -p2

There will be an error as the ChangeLog file won't be found, but that
can be safely ignored. After that the patch will be applied and you'll
be able to set the linewidth with contours. However, the above might
need to be done as root.

D.

_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave