plot templates and options lists for set, plot etc.

Ben Abbott bpabbott at mac.com
Wed Jun 24 18:48:20 CDT 2009


On Jun 24, 2009, at 12:56 PM, John W. Eaton wrote:

> On 22-Jun-2009, Thorsten Meyer wrote:
>
> | I have come quite far in implementing the struct case and the 1XN  
> cell
> | array case in graphics_object::set. However, for the MxN cell array
> | case, I am not sure what to do:
> |
> | should the MxN case be dealt with in DEFUN set, extracting the  
> rows out
> | of property_values and passing them to the set method of the
> | corresponding graphics objects?
> |   or
> | should a special input argument be added to the set method (or a new
> | set_n method)  which allows to select a row of the passed  
> property_values?
> |
> | Also, for the struct case: what does matlab do in case h is a  
> vector of
> | handles and struct is a struct array? Does it deal the elements of  
> the
> | struct array to the elements of h? I.e. is set(h,struct)  
> equivalent to
> | set(h(1), struct(1)); set(h(2), struct(2)); ...? The matlab
> | documentation  isn't clear about this.
>
> I'm not sure what the best solution is.
>
> Could someone with a current version of Matlab try the following and
> report back about what it does?
>
>  h(1) = line (rand (3, 1), rand (3, 1));
>  h(2) = line (rand (3, 1), rand (3, 1));
>  s(1).Color 'red';
>  s(2).Color 'green';
>  set (h, s);
>
> Thanks,
>
> jwe

I'm running Matlab 2009a

x = 0:0.01:5;
h(1) = line (x, sin(x));
h(2) = line (x, cos(x));
s(1,1).Color = 'red';
s(1,2).Color = 'green';
set (h, s);
color = get (h, 'color');
color{:}
ans =
      0     1     0
ans =
      0     1     0

I'd expected the lines to have different colors.

I also tried the following ...

property_names = {'color', 'color'};
property_values = {[1,0,0], [0,1,0]};
set (h, property_names, property_values)
color = get (h, 'color');
color{:}
ans =
      0     1     0
ans =
      0     1     0

It appears that the property names and values are each applied to all  
handles. The green sticks because it was set last.

However, I'm not convinced the first example (with the structures) is  
intentional. Perhaps it makes sense for Octave to handle this in the  
expected manner.

Ben








More information about the Octave-maintainers mailing list