octave-maintainers
[Top][All Lists]
Advanced

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

Re: plot templates and options lists for set, plot etc.


From: Thorsten Meyer
Subject: Re: plot templates and options lists for set, plot etc.
Date: Sun, 05 Jul 2009 21:01:40 +0200
User-agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103)

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.

Thorsten


reply via email to

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