|
From: Ethan A M. <sf...@us...> - 2017-10-09 20:13:34
|
On Monday, 09 October, 2017 20:19:43 Achim Gratz wrote:
> sfeam via gnuplot-beta writes:
> > Too complicated for me to work through in detail but one line
> > is waving a red flag. This line
> > set ytics @ticdef
> > is almost certainly not what you want to do.
>
> Ah, OK.
>
> > The macro expansion operator @ is like a #define statement in C.
> > It causes a substitution at the time the file/block/clause/program unit
> > is read in. It is _not_ reevaluated at run time.
>
> I still can't quite figure out the consitions under which this was and
> wasn't working for my example in various stages of its development, but
> I think that must be the right explanation.
>
> > An example of evaluation at run time would be:
> >
> > ... loop that constructs ticdef ...
> > eval "set ytics " . ticdef
>
> This seems all unnecessarily involved, so maybe I should rather ask if
> there's a way to build up an explicit tics list piece by piece rather
> than having to feed everyting as one single giant string?
Yes. The keyword "add" does what you want.
# x labels at 1 2 3 ... and also at certain interesting values
array label[4] = ["sqrt(2)", "sqrt(3)", "e", "pi"]
array value[4] = [1.414, 1.732, exp(1), pi]
set xtics 1.0
do for [i=1:4] {
set xtics add (label[i] value[i])
}
> Also, why is there no block "else if" or maybe even "elsif"?
No particular reason.
So far as I can see, all it would gain is to reduce the number of
required curly brackets by one pair.
Is there something more subtle I'm missing?
Ethan
>
> Regards,
> Achim.
>
|