Re: How to pass additional parameters to the ticks function?
- To: mathgroup at smc.vnet.net
- Subject: [mg108648] Re: How to pass additional parameters to the ticks function?
- From: Brett Champion <brettc at wolfram.com>
- Date: Fri, 26 Mar 2010 05:35:12 -0500 (EST)
On Mar 25, 2010, at 4:28 AM, Nasser M. Abbasi wrote:
> background:
>
> When plotting, one can supply a specific tick function, which is
> automatically called by the Plot code. This allows one to have
> control on
> how the ticks are set.
>
> This is useful. Here is an example:
>
> ------------------------------
> ticksX[min_, max_] := Table[{i, Style[i, Red, 12], {0.04, 0}},
> {i, Ceiling[min], Floor[max]}]
>
> Plot[Sin[x], {x, 0, 4}, Ticks -> {ticksX, Automatic}]
> -------------------------------
>
> The only problem with the above design, is that sometimes one might
> want to
> have additional information inside the ticks function, other than
> just the
> min and the max ticks values, to help it decide what to do.
>
> Assume this additional information is some variable, say T.
>
> Right now, the only way to access this variable from inside the ticks
> function, is to have T be global. I prefer not to use global
> variables/symbols.
>
> It would be much better if Ticks would take additional, and optional
> parameter, to pass to the ticks function.
>
> May be something like
>
> ------------------------------------
> ticksX[min_, max_,extra_List] := If[ extra[[1]]==.... etc.....]
>
>
> Plot[Sin[x], {x, 0, 4}, Ticks -> {ticksX[{T}], Automatic}]
With the definition for ticksX as above, use:
Ticks -> {ticksX[##, {T}]&, Automatic}
Or you can define ticksX as:
ticksX[extra_List][min_, max_] := If[ extra[[1]]==.... etc.....]
in which case your Plot[] code
Plot[Sin[x], {x, 0, 4}, Ticks -> {ticksX[{T}], Automatic}]
will work.
Brett Champion
Wolfram Research
> ---------------------------------------
>
> And now inside my ticks function, I can access the additional
> information if
> I want to use it to help me set the ticks.
>
> If the above is not possible in version 7, is it possible to make this
> enhancement available in version 8?
>
> --Nasser
>
>
>
>
>