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: Ben Abbott
Subject: Re: plot templates and options lists for set, plot etc.
Date: Sun, 05 Jul 2009 11:37:47 -0400


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


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

Ben




reply via email to

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