MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: SetOptions[Plot, .Z..] vs using Plot[, .Z..] behaves differently when Z is Dynamics

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105514] Re: [mg105507] SetOptions[Plot, .Z..] vs using Plot[, .Z..] behaves differently when Z is Dynamics
  • From: John Fultz <jfultz at wolfram.com>
  • Date: Sun, 6 Dec 2009 01:30:44 -0500 (EST)
  • Reply-to: jfultz at wolfram.com

This isn't a problem with Dynamic at all.  If you cleared maxy beforehand, it 
would have worked.  Take a look at the SetOptions command.  You're not using
RuleDelayed!  Any previous assignment of maxy is going to be dropped literally 
into the option, rather than the symbol 'maxy'.

Your attempted explanation would only hold water if the Dynamic were on the rhs 
of the option, and the option weren't exposed in the FE (which PlotRange is).  
Having Dynamic wrapped around the entire plotting command guarantees the 
re-evaluation with no problem at all.

Sincerely,
 
John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.


On Sat, 5 Dec 2009 06:35:24 -0500 (EST), Nasser M. Abbasi wrote:
> ver 7
>
> I think this is an expected behavior which can be explained by some
> expert, but I found it really strange.
>
> The following 2 pieces of code _look_ that they should be equivalent, but
> one work as expected, and the other do not work as one might expect it to
>
> ------- code 1 -----------------
> ver = VerticalSlider[Dynamic[maxy], {0.1, 4}, Appearance -> "LeftArrow"];
> SetOptions[Plot, PlotRange -> {{-Pi, Pi}, {-maxy, maxy}}];
> p = Dynamic[Plot[Cos[x], {x, -Pi, Pi}]];
> Row[{ver, p}]
>
>
> ---- code 2, works as expected ----------------
> ver = VerticalSlider[Dynamic[maxy], {0.1, 4}, Appearance -> "LeftArrow"];
> p = Dynamic[Plot[Cos[x], {x, -Pi, Pi}, PlotRange -> {{-Pi, Pi}, {-maxy,
> maxy}}]];
> Row[{ver, p}]
>
>
> I simply moved the PlotRange options and set it as a default option using
> SetOptions.
>
> btw, writing Dynamic at SetOptions[...] did not help. Also doing
> Dynamics@maxy
> did not help.
>
> My thinking of why this is so, is that SetOptions is processed by the
> kernel, not the front end, and so the fact that maxy is Dynamic is lost
> as the kernel do not know about Dynamcis only the front end. or something
> along these line?
>
> Is there a way to make SetOptions work with Dynamics as if the options
> were part of the Plot command itself?
>
> --Nasser





  • Prev by Date: Re: How to combine Dynamic graphics in Show?
  • Next by Date: Re: How to combine Dynamic graphics in Show?
  • Previous by thread: Re: SetOptions[Plot,.Z..] vs using Plot[,.Z..] behaves
  • Next by thread: how to perform ninefold integration