contourf and edgecolor

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

contourf and edgecolor

by Marco Caliari-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear maintainers,

I noticed that

contourf(peaks,'EdgeColor','red')

gives

error: subscript indices must be either positive integers or logicals.
error: called from:
error:   /usr/local/share/octave/3.2.2/m/plot/__add_datasource__.m at line
42, column 5
error:   /usr/local/share/octave/3.2.2/m/plot/__contour__.m at line 110,
column 8
error:   /usr/local/share/octave/3.2.2/m/plot/contourf.m at line 73,
column 5

(Octave 3.2.2, gnuplot 4.2.5). I easily fixed this problem, changing

strcmpi (arg(end-9:end), "datasource")

with

strcmpi (arg(max(end-9,1):end), "datasource")

but then I get

error: set: unknown property "EdgeColor"
error: called from:
error:   /usr/local/share/octave/3.2.2/m/plot/__contour__.m at line 191,
column 5
error:   /usr/local/share/octave/3.2.2/m/plot/contourf.m at line 73,
column 5

No problem in Octave 3.0.5 or ml.

Best regards,

Marco
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave

Re: contourf and edgecolor

by dbateman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Marco Caliari-4 wrote:
Dear maintainers,

I noticed that

contourf(peaks,'EdgeColor','red')

gives

error: subscript indices must be either positive integers or logicals.
error: called from:
error:   /usr/local/share/octave/3.2.2/m/plot/__add_datasource__.m at line
42, column 5
error:   /usr/local/share/octave/3.2.2/m/plot/__contour__.m at line 110,
column 8
error:   /usr/local/share/octave/3.2.2/m/plot/contourf.m at line 73,
column 5

(Octave 3.2.2, gnuplot 4.2.5). I easily fixed this problem, changing

strcmpi (arg(end-9:end), "datasource")

with

strcmpi (arg(max(end-9,1):end), "datasource")

but then I get

error: set: unknown property "EdgeColor"
error: called from:
error:   /usr/local/share/octave/3.2.2/m/plot/__contour__.m at line 191,
column 5
error:   /usr/local/share/octave/3.2.2/m/plot/contourf.m at line 73,
column 5

No problem in Octave 3.0.5 or ml.

Best regards,

Marco
_______________________________________________
Bug-octave mailing list
Bug-octave@octave.org
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave
I can't patch this now, but changing the line

&& length (arg) > 1 && strcmpi (arg(end-9:end), "datasource")

to

&& length (arg) > 9 && strcmpi (arg(end-9:end), "datasource")

and it will work correctly. I believe it should be 'LineColor' and not 'EdgeColor' for this case as well. Can someone generate and apply the patch for me?

Cheers
David

Re: contourf and edgecolor

by dbateman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


dbateman wrote:
Marco Caliari-4 wrote:
Dear maintainers,

I noticed that

contourf(peaks,'EdgeColor','red')

gives

error: subscript indices must be either positive integers or logicals.
error: called from:
error:   /usr/local/share/octave/3.2.2/m/plot/__add_datasource__.m at line
42, column 5
error:   /usr/local/share/octave/3.2.2/m/plot/__contour__.m at line 110,
column 8
error:   /usr/local/share/octave/3.2.2/m/plot/contourf.m at line 73,
column 5

(Octave 3.2.2, gnuplot 4.2.5). I easily fixed this problem, changing

strcmpi (arg(end-9:end), "datasource")

with

strcmpi (arg(max(end-9,1):end), "datasource")

but then I get

error: set: unknown property "EdgeColor"
error: called from:
error:   /usr/local/share/octave/3.2.2/m/plot/__contour__.m at line 191,
column 5
error:   /usr/local/share/octave/3.2.2/m/plot/contourf.m at line 73,
column 5

No problem in Octave 3.0.5 or ml.

Best regards,

Marco
_______________________________________________
Bug-octave mailing list
Bug-octave@octave.org
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave
I can't patch this now, but changing the line

&& length (arg) > 1 && strcmpi (arg(end-9:end), "datasource")

to

&& length (arg) > 9 && strcmpi (arg(end-9:end), "datasource")

and it will work correctly. I believe it should be 'LineColor' and not 'EdgeColor' for this case as well. Can someone generate and apply the patch for me?

Cheers
David
The patch is in __add_datasource__.m around line 43

D.


Parent Message unknown Re: contourf and edgecolor

by Marco Caliari-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear David,

yes, 'LineColor' works. On the other hand, it does not work in Octave
3.0.5 (while 'EdgeColor' works) and 'EdgeColor', although not mentioned in
the docs, appears to be a synonym for 'LineColor' in Matlab (at least for
contourf). I would suggest to keep it as a synonym.

Thanks,

Marco
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave

Re: contourf and edgecolor

by dbateman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Marco Caliari-4 wrote:
Dear David,

yes, 'LineColor' works. On the other hand, it does not work in Octave
3.0.5 (while 'EdgeColor' works) and 'EdgeColor', although not mentioned in
the docs, appears to be a synonym for 'LineColor' in Matlab (at least for
contourf). I would suggest to keep it as a synonym.

Thanks,

Marco
_______________________________________________
Bug-octave mailing list
Bug-octave@octave.org
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave
Ok, then a new patch is need for the contourgroup making edgecolor a synonym to linecolor. I'll see what I can do over the weekend

D.

Re: contourf and edgecolor

by Ben Abbott :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Aug 21, 2009, at 9:26 AM, dbateman wrote:

> Marco Caliari-4 wrote:
>>
>> Dear David,
>>
>> yes, 'LineColor' works. On the other hand, it does not work in Octave
>> 3.0.5 (while 'EdgeColor' works) and 'EdgeColor', although not  
>> mentioned in
>> the docs, appears to be a synonym for 'LineColor' in Matlab (at  
>> least for
>> contourf). I would suggest to keep it as a synonym.
>>
>> Thanks,
>>
>> Marco
>> _______________________________________________
>> Bug-octave mailing list
>> Bug-octave@...
>> https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave
>>
>>
>
> Ok, then a new patch is need for the contourgroup making edgecolor a  
> synonym
> to linecolor. I'll see what I can do over the weekend
>
> D.

David, I have a faint recollection that you may no longer have access  
to a current Matlab license (?).

What I see is more complicated than I'd expected, but appears straight  
forward (not for me as I've never bother to dig into the details of  
the hggroup).

 >> [c,h] = contour(rand(10,10));
 >> get (h, 'linecolor')

ans =

auto

 >> get (h, 'edgecolor')

ans =

flat

 >> set (h, 'linecolor', 'b')
 >> get (h, 'edgecolor')

ans =

      0     0     1

 >> set (h, 'linecolor', 'auto')
 >> get (h, 'edgecolor')

ans =

flat

 >> set (h, 'edgecolor', [0 0 1])
 >> get (h, 'linecolor')

ans =

      0     0     1

 >> set (h, 'edgecolor', 'flat')
 >> get (h, 'linecolor')

ans =

auto

 >> set (h, 'edgecolor', [0 0 1])
 >> set (h, 'linecolor', [0 0 1])
 >> set (h, 'edgecolor', 'flat')
 >> get (h, 'linecolor')

ans =

auto

Ben

p.s. This has to go under WWMTT ... maybe we should start a list for  
"What Was MathWorks Thinking"? ;-)

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave

Re: contourf and edgecolor

by dbateman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ben Abbott wrote:

> On Aug 21, 2009, at 9:26 AM, dbateman wrote:
>
>  
>> Marco Caliari-4 wrote:
>>    
>>> Dear David,
>>>
>>> yes, 'LineColor' works. On the other hand, it does not work in Octave
>>> 3.0.5 (while 'EdgeColor' works) and 'EdgeColor', although not  
>>> mentioned in
>>> the docs, appears to be a synonym for 'LineColor' in Matlab (at  
>>> least for
>>> contourf). I would suggest to keep it as a synonym.
>>>
>>> Thanks,
>>>
>>> Marco
>>> _______________________________________________
>>> Bug-octave mailing list
>>> Bug-octave@...
>>> https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave
>>>
>>>
>>>      
>> Ok, then a new patch is need for the contourgroup making edgecolor a  
>> synonym
>> to linecolor. I'll see what I can do over the weekend
>>
>> D.
>>    
>
> David, I have a faint recollection that you may no longer have access  
> to a current Matlab license (?).
>
> What I see is more complicated than I'd expected, but appears straight  
> forward (not for me as I've never bother to dig into the details of  
> the hggroup).
>
>  >> [c,h] = contour(rand(10,10));
>  >> get (h, 'linecolor')
>
> ans =
>
> auto
>
>  >> get (h, 'edgecolor')
>
> ans =
>
> flat
>
>  >> set (h, 'linecolor', 'b')
>  >> get (h, 'edgecolor')
>
> ans =
>
>       0     0     1
>
>  >> set (h, 'linecolor', 'auto')
>  >> get (h, 'edgecolor')
>
> ans =
>
> flat
>
>  >> set (h, 'edgecolor', [0 0 1])
>  >> get (h, 'linecolor')
>
> ans =
>
>       0     0     1
>
>  >> set (h, 'edgecolor', 'flat')
>  >> get (h, 'linecolor')
>
> ans =
>
> auto
>
>  >> set (h, 'edgecolor', [0 0 1])
>  >> set (h, 'linecolor', [0 0 1])
>  >> set (h, 'edgecolor', 'flat')
>  >> get (h, 'linecolor')
>
> ans =
>
> auto
>
> Ben
>  
The attached patch, that I pushed, seems to duplicate this behavior.
Perhaps it should be applied to 3.2.x as well (at least the change to
__add_datasource__ should as that is a real bug).

> p.s. This has to go under WWMTT ... maybe we should start a list for  
> "What Was MathWorks Thinking"? ;-)
>  
I thought is good geek style that should be WTFWMT ;-)

D.



# HG changeset patch
# User David Bateman <dbateman@...>
# Date 1250970507 -7200
# Node ID bda3513e7ba92cf3026eed6cf469fcd4c84c63d0
# Parent  0c72d928408776cfc4fc7ab6495357dce1f1b4af
Fix test for setting of datasource properties. Add the edgecolor property to contours

diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,9 @@
+2009-08-22  David Bateman  <dbateman@...>
+
+ * plot/__add_datasource__.m: Correct test for "datasource" argument
+ * plot/__countour__.m: Add edgecolor properties and make it an alias
+ for linecolor with the value "auto" being "flat" for the edgecolor.
+
 2009-08-17  John W. Eaton  <jwe@...>
 
  * help/print_usage.m: Make it work again if an argument is given.
diff --git a/scripts/plot/__add_datasource__.m b/scripts/plot/__add_datasource__.m
--- a/scripts/plot/__add_datasource__.m
+++ b/scripts/plot/__add_datasource__.m
@@ -40,7 +40,7 @@
   while (i < numel (varargin))
     arg = varargin{++i};
     if (i != numel(varargin) && ischar (arg)
- && length (arg) > 1 && strcmpi (arg(end-9:end), "datasource"))
+ && length (arg) > 9 && strcmpi (arg(end-9:end), "datasource"))
       arg = tolower (arg);
       val = varargin{++i};
       if (ischar (val))
diff --git a/scripts/plot/__contour__.m b/scripts/plot/__contour__.m
--- a/scripts/plot/__contour__.m
+++ b/scripts/plot/__contour__.m
@@ -28,6 +28,7 @@
 
   linespec.linestyle = "-";
   linespec.color = "auto";
+  edgecolor = "flat";
   for i = 3 : nargin
     arg = varargin {i};
     if ((ischar (arg) || iscell (arg)))
@@ -52,6 +53,17 @@
  varargin(i:i+1) = [];
       elseif (strcmpi (varargin{i}, "linecolor"))
  linespec.color = varargin {i + 1};
+ edgecolor = linespec.color;
+ if (ischar (edgecolor) && strcmpi (edgecolor, "auto"))
+  edgecolor = "flat";
+ endif
+ varargin(i:i+1) = [];
+      elseif (strcmpi (varargin{i}, "edgecolor"))
+ linespec.color = varargin {i + 1};
+ edgecolor = linespec.color;
+ if (ischar (edgecolor) && strcmpi (edgecolor, "flat"))
+  linespec.color = "auto";
+ endif
  varargin(i:i+1) = [];
       else
  opts{end+1} = varargin{i};
@@ -164,6 +176,10 @@
   addproperty ("linestyle", hg, "linelinestyle", linespec.linestyle);
   addproperty ("linewidth", hg, "linelinewidth", 0.5);
 
+  ## FIXME It would be good to hide this property which is just an undocumented
+  ## alias for linecolor
+  addproperty ("edgecolor", hg, "color", edgecolor, "{flat}|none");
+
   addlistener (hg, "fill", @update_data);
 
   addlistener (hg, "zlevelmode", @update_zlevel);
@@ -185,6 +201,8 @@
   addlistener (hg, "linestyle", @update_line);
   addlistener (hg, "linewidth", @update_line);
 
+  addlistener (hg, "edgecolor", @update_edgecolor);
+
   add_patch_children (hg);
 
   if (!isempty (opts))
@@ -366,11 +384,27 @@
   endswitch
 endfunction
 
+function update_edgecolor (h, d)
+  ec = get (h, "edgecolor");
+  lc = get (h, "linecolor");
+  if (ischar (ec) && strcmpi (ec, "flat"))
+    if (! strcmpi (lc, "auto"))
+      set (h, "linecolor", "auto");
+    endif
+  elseif (! isequal (ec, lc))
+    set (h, "linecolor", ec);
+  endif
+endfunction
+
 function update_line (h, d)
   lc = get (h, "linecolor");
+  ec = get (h, "edgecolor");
   if (strcmpi (lc, "auto"))
     lc = "flat";
   endif
+  if (! isequal (ec, lc))
+    set (h, "edgecolor", lc);
+  endif
   set (findobj (h, "type", "patch"), "edgecolor", lc,
        "linewidth", get (h, "linewidth"), "linestyle", get (h, "linestyle"));
 endfunction

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave