plot templates and options lists for set, plot etc.

Thorsten Meyer thorsten.meyier at gmx.de
Sun Jul 5 15:24:17 CDT 2009


Thorsten Meyer wrote:
> Hi,
> 
> thanks a lot for the quick response.
> 
> Ben Abbott wrote:
>> On Jul 5, 2009, at 7:23 AM, Thorsten Meyer wrote:
>>
>>> Hi,
>>>> 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.
>>> Could you also try
>>>    h(1) = line (x, sin(x));
>>>    h(2) = line (x, cos(x));
>>>    s(1,1).Color = 'red';
>>>    s(2,1).Color = 'green';
>>>    set (h, s);
>>>    color = get (h, 'color');
>>>    color{:}
>>> ?
>> My usual computer is in for repair. My second machine is PPC based and
>> is only able to run Matlab R2007b. I had to add the 3rd line below to
>> run your script, but the results are not correct.
>>
>>>> h(1) = line (x, sin(x));
>>>> h(2) = line (x, cos(x));
>>>> s = struct ();
>>>> s(1,1).Color = 'red';
>>>> s(2,1).Color = 'green';
>>>> set (h, s);
>>>> color = get (h, 'color');
>>>> color{:}
>>>> ans =
>>      0     1     0
>>>> ans =
>>      0     1     0
>>
> So, matlab sets all elements of the properties structure for each of the
> handles in h independent of the dimensions of the structure (unless they
> have changed it in the 2009 version). Or, nicer to implement: it sets
> the values found in the last elements of the struct array fields.
>>>> 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.
>>> Could you try again with
>>>    property_names = {'color'};
>>>    property_values = {[1,0,0]; [0,1,0]};
>>>    set (h, property_names, property_values)
>>>    color = get (h, 'color');
>>>    color{:}
>>> ?
>>>> property_names = {'color'};
>>>> property_values = {[1,0,0]; [0,1,0]};
>>>> set (h, property_names, property_values)
>> ??? Error using ==> set
>> Value cell array handle dimension must match handle vector length.
>>
>> But this does work
>>
>>>> x = 0:0.01:5;
>>>> h(1,1) = line (x, sin(x));
>>>> h(2,1) = line (x, cos(x));
>>>> pn = {'Color'};
>>>> pv = {'red'; 'green'};
>>>> set (h, pn, pv);
>>>> color = get (h, 'color');
>>>> color{:}
>>>> ans =
>>      1     0     0
>>>> ans =
>>      0     1     0
> Ok, so matlab really wants to have values meant for different elements
> of the handle vector in the rows of the values cell array.
> 
> I'll put this behaviour in my patch for the set function.
> 
Here is a patch implementing struct and cell array arguments for the set function.

I have impplemented the matlab behaviour (as I understand it ...). See the tests
 added to the patch for the details.

Could somebody please review the patch (what I do in the sources is still a lot
of trial and error):
 - Have I got the types of the various variables right?
 - Is it ok to add doxygen style comments to the new methods? (the doxygen docs
have helped me a lot to find my way in the sources)
 - What about the coding style?
 - Are the added methods for the graphics_object ok (also where I placed the
definitions)?

Thanks

Thorsten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: set_syntax_extension.patch
Type: text/x-patch
Size: 9625 bytes
Desc: not available
Url : https://www-old.cae.wisc.edu/pipermail/octave-maintainers/attachments/20090705/d9ec7743/attachment.bin 


More information about the Octave-maintainers mailing list