help-octave
[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: Sat, 06 Jun 2009 18:43:04 +0200
User-agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103)

Hi,

Ben Abbott wrote:
>
> On Jun 6, 2009, at 11:21 AM, Thorsten Meyer wrote:
>
>> Hi,
>>
>> at work, I often have to generate the same kind of plots with
>> particular labels,
>> line styles, etc.. I would like to create templates for these plots.
>> For this, I
>> collect plot options in a struct like it is returned by the get
>> function. E.g.
>>  style = struct("linewidth", 2, "marker", "x", "markersize", 12);
>>
>> Now, I want to pass these options to the plot function. At the
>> moment, I do it
>> like this:
>>  plot(1:5, 5:-1:1, {fieldnames(style)'{:}; struct2cell(style)'{:}}{:});
>>
>> [...]
>
> Would you prefer the approach below?
>
>     props = {"color", [0 1 0], "marker", "s"}
>     h = plot (1:10);
>     set (h, props{:})
>
> If you want to continue to use your structure, you can populate props
> by ...
>
>     props = [fieldnames(style), struct2cell(style)];
>
> But that is not really very different from what you're already doing.
Yes, I have seen, that the options are collected into a cell array
within the plot functions. However, keeping the options in a structure
has the advantage, that I can easily access and set the individual
options, e.g. to transform one plot template into a new one,  etc.
Also, how are graphic objects realized internally? Aren't they also
structures? It always seemed quite strange to me, that the get()
function returns a structure, while all the functions setting handle
options take lists of key, value,... as input arguments...

Thorsten




reply via email to

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