From: Alexei Boulbitch on
From: "John Fultz" <jfultz at wolfram.com>


"Show doesn't know how to deal with something that has the head Dynamic."....

Let me give a counter-example. In what follows I show a piece of code from one of my presentations, and I am much too lazy
to shorten it for the purposes of demonstrating within this discussion. Please excuse me. Anyway, it contains several definitions
of equations to be drawn that are irrelevant for the present discussion. However, in the
code part that is entitled "MainPart" you will find the Show statement wrapped around Dynamic (and also the
DynamicModule wrapped around Show). Everything functions as desired. Please have a look:


g1[x_] := If[x <= 0, (3*x^2)/16, 0];
g2[x_] := If[x <= 0, x^2/4, 0];
g3[x_] := 0;
eta2[t_, b_] := If[t - 1 > 0, 0, 2.*Sqrt[-(t - 1)/(b + 0.01)]];
eta1[t_, b_] :=
If[t - 1 >= (3*b^2)/16, 0,
0.7*(Sqrt[3*Abs[b]]/2 + Sqrt[-(t - 1) + b^2/4])];
eta[t_, b_] := If[b >= 0, eta2[t, b], eta1[t, b]];

point[a_, b_] := Disk[{b, a}, 0.1];
pl = Plot[{Tooltip[g1[x], "f(\[Eta]\[NotEqual]0)=f(\[Eta]=0)"],
Tooltip[g2[x],
"(\!\(\*SuperscriptBox[\"d\", \"2\"]\)f/\!\(\*SuperscriptBox[\"d\
\[Eta]\", \"2\"]\)\!\(\*SubscriptBox[\")\",
RowBox[{\"\[Eta]\", \"\[NotEqual]\", \"0\"}]]\)=0"],
Tooltip[g3[x],
"(\!\(\*SuperscriptBox[\"d\", \"2\"]\)f/\!\(\*SuperscriptBox[\"d\
\[Eta]\", \"2\"]\)\!\(\*SubscriptBox[\")\",
RowBox[{\"\[Eta]\", \"=\", \"0\"}]]\)=0"]}, {x, -4, 2},
PlotRange -> {{-4, 2}, {-2, 3}}, PlotStyle -> Thick, Axes -> True,
Ticks -> None, AxesLabel -> {\[Beta], \[Alpha]},
LabelStyle -> Directive[Large], ImageSize -> 350,
Epilog -> {Inset[
Text[Style["\[Eta]=0", FontSize -> 20]], {1.5, 2.5}],
Inset[Text[
Style["\[Eta]\[NotEqual]0", FontSize -> 20]], {-1, -1.5}] },
Filling -> {2 -> {3}},
PlotLabel -> Style["Phase Diagram", 20, Red, Bold]];



MainPart =
DynamicModule[{pt = {1.7, 2}},
GraphicsColumn[{Show[{pl, Graphics[Locator[Dynamic[pt]]]},
ImageSize -> 500],
GraphicsRow[{Dynamic[
Plot[pt[[2]] x^2/2 + pt[[1]] x^4/4 + x^6/6, {x, -3, 3},
PlotRange -> {{-4, 4}, {-2, 3}}, Axes -> True, Ticks -> None,
AxesLabel -> {Style[\[Eta], Large, Plain,
FontFamily -> "Symbol"],
Style["f", Large, Italic, FontFamily -> "Times New Roman"]},
PlotStyle -> {Thick, Blue}, LabelStyle -> Directive[Large],
PlotLabel -> Style["Landau Potential", 20, Red, Bold] (*,
ImageSize->400*)]],
Dynamic[Plot[
Tooltip[eta[t, pt[[1]]], "\!\(\*SqrtBox[FractionBox[
RowBox[{
RowBox[{\"-\", \"\[Beta]\"}], \"+\", SqrtBox[
RowBox[{SuperscriptBox[\"\[Beta]\", \"2\"], \"-\",
RowBox[{\"4\", \"\[Alpha]\[Gamma]\"}]}]]}],
RowBox[{\"2\", \"\[Gamma]\"}]]]\)"], {t, pt[[2]] + 1, 3.2},
PlotRange -> {{0, 3}, {0, 2.5}},(*ImageSize->400,*)
PlotStyle -> {Thick, Blue}, Ticks -> None, Axes -> True,
AxesLabel -> {T, \[Eta]},
PlotLabel -> Style["Order Parameter", 20, Red, Bold],
LabelStyle -> Directive[Large]]]}, ImageSize -> 700,
Spacings -> 70]}, Spacings -> -350]]


Regards, Alexei


--
Alexei Boulbitch, Dr., habil.
Senior Scientist

IEE S.A.
ZAE Weiergewan
11, rue Edmond Reuter
L-5326 Contern
Luxembourg

Phone: +352 2454 2566
Fax: +352 2454 3566

Website: www.iee.lu

This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you are not the intended recipient and have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal from your system. Thank you for your co-operation.



From: DrMajorBob on
Your Show sees only graphics in your example:

Show[{pl, Graphics[...]}, ImageSize -> 500]

pl has head Graphics, and so does the second list item.

Yes, the "..." includes Dynamic, but Show isn't seeing that.

Bobby

On Tue, 08 Dec 2009 05:43:08 -0600, Alexei Boulbitch
<Alexei.Boulbitch(a)iee.lu> wrote:

> From: "John Fultz" <jfultz at wolfram.com>
>
>
> "Show doesn't know how to deal with something that has the head
> Dynamic."....
>
> Let me give a counter-example. In what follows I show a piece of code
> from one of my presentations, and I am much too lazy
> to shorten it for the purposes of demonstrating within this discussion.
> Please excuse me. Anyway, it contains several definitions
> of equations to be drawn that are irrelevant for the present discussion.
> However, in the
> code part that is entitled "MainPart" you will find the Show statement
> wrapped around Dynamic (and also the
> DynamicModule wrapped around Show). Everything functions as desired.
> Please have a look:
>
>
> g1[x_] := If[x <= 0, (3*x^2)/16, 0];
> g2[x_] := If[x <= 0, x^2/4, 0];
> g3[x_] := 0;
> eta2[t_, b_] := If[t - 1 > 0, 0, 2.*Sqrt[-(t - 1)/(b + 0.01)]];
> eta1[t_, b_] :=
> If[t - 1 >= (3*b^2)/16, 0,
> 0.7*(Sqrt[3*Abs[b]]/2 + Sqrt[-(t - 1) + b^2/4])];
> eta[t_, b_] := If[b >= 0, eta2[t, b], eta1[t, b]];
>
> point[a_, b_] := Disk[{b, a}, 0.1];
> pl = Plot[{Tooltip[g1[x], "f(\[Eta]\[NotEqual]0)=f(\[Eta]=0)"],
> Tooltip[g2[x],
> "(\!\(\*SuperscriptBox[\"d\", \"2\"]\)f/\!\(\*SuperscriptBox[\"d\
> \[Eta]\", \"2\"]\)\!\(\*SubscriptBox[\")\",
> RowBox[{\"\[Eta]\", \"\[NotEqual]\", \"0\"}]]\)=0"],
> Tooltip[g3[x],
> "(\!\(\*SuperscriptBox[\"d\", \"2\"]\)f/\!\(\*SuperscriptBox[\"d\
> \[Eta]\", \"2\"]\)\!\(\*SubscriptBox[\")\",
> RowBox[{\"\[Eta]\", \"=\", \"0\"}]]\)=0"]}, {x, -4, 2},
> PlotRange -> {{-4, 2}, {-2, 3}}, PlotStyle -> Thick, Axes -> True,
> Ticks -> None, AxesLabel -> {\[Beta], \[Alpha]},
> LabelStyle -> Directive[Large], ImageSize -> 350,
> Epilog -> {Inset[
> Text[Style["\[Eta]=0", FontSize -> 20]], {1.5, 2.5}],
> Inset[Text[
> Style["\[Eta]\[NotEqual]0", FontSize -> 20]], {-1, -1.5}] },
> Filling -> {2 -> {3}},
> PlotLabel -> Style["Phase Diagram", 20, Red, Bold]];
>
>
>
> MainPart =
> DynamicModule[{pt = {1.7, 2}},
> GraphicsColumn[{Show[{pl, Graphics[Locator[Dynamic[pt]]]},
> ImageSize -> 500],
> GraphicsRow[{Dynamic[
> Plot[pt[[2]] x^2/2 + pt[[1]] x^4/4 + x^6/6, {x, -3, 3},
> PlotRange -> {{-4, 4}, {-2, 3}}, Axes -> True, Ticks -> None,
> AxesLabel -> {Style[\[Eta], Large, Plain,
> FontFamily -> "Symbol"],
> Style["f", Large, Italic, FontFamily -> "Times New Roman"]},
> PlotStyle -> {Thick, Blue}, LabelStyle -> Directive[Large],
> PlotLabel -> Style["Landau Potential", 20, Red, Bold] (*,
> ImageSize->400*)]],
> Dynamic[Plot[
> Tooltip[eta[t, pt[[1]]], "\!\(\*SqrtBox[FractionBox[
> RowBox[{
> RowBox[{\"-\", \"\[Beta]\"}], \"+\", SqrtBox[
> RowBox[{SuperscriptBox[\"\[Beta]\", \"2\"], \"-\",
> RowBox[{\"4\", \"\[Alpha]\[Gamma]\"}]}]]}],
> RowBox[{\"2\", \"\[Gamma]\"}]]]\)"], {t, pt[[2]] + 1, 3.2},
> PlotRange -> {{0, 3}, {0, 2.5}},(*ImageSize->400,*)
> PlotStyle -> {Thick, Blue}, Ticks -> None, Axes -> True,
> AxesLabel -> {T, \[Eta]},
> PlotLabel -> Style["Order Parameter", 20, Red, Bold],
> LabelStyle -> Directive[Large]]]}, ImageSize -> 700,
> Spacings -> 70]}, Spacings -> -350]]
>
>
> Regards, Alexei
>
>


--
DrMajorBob(a)yahoo.com

From: John Fultz on
This is not a counter-example. As you quoted me, I said that Show "doesn't know
how to deal with something that has the head Dynamic." But what you passed it
were two things with the head Graphics. What's inside the Graphics object is
totally irrelevant (so long as it's renderable, of course).

Sincerely,

John Fultz
jfultz(a)wolfram.com
User Interface Group
Wolfram Research, Inc.


On Tue, 8 Dec 2009 06:43:08 -0500 (EST), Alexei Boulbitch wrote:
> From: "John Fultz" <jfultz at wolfram.com>
>
>
> "Show doesn't know how to deal with something that has the head
> Dynamic."....
>
> Let me give a counter-example. In what follows I show a piece of code
> from one of my presentations, and I am much too lazy
> to shorten it for the purposes of demonstrating within this discussion.
> Please excuse me. Anyway, it contains several definitions
> of equations to be drawn that are irrelevant for the present discussion.
> However, in the
> code part that is entitled "MainPart" you will find the Show statement
> wrapped around Dynamic (and also the
> DynamicModule wrapped around Show). Everything functions as desired.
> Please have a look:
>
>
> g1[x_] := If[x <= 0, (3*x^2)/16, 0];
> g2[x_] := If[x <= 0, x^2/4, 0];
> g3[x_] := 0;
> eta2[t_, b_] := If[t - 1 > 0, 0, 2.*Sqrt[-(t - 1)/(b + 0.01)]];
> eta1[t_, b_] :=
> If[t - 1 >= (3*b^2)/16, 0,
> 0.7*(Sqrt[3*Abs[b]]/2 + Sqrt[-(t - 1) + b^2/4])];
> eta[t_, b_] := If[b >= 0, eta2[t, b], eta1[t, b]];
>
> point[a_, b_] := Disk[{b, a}, 0.1];
> pl = Plot[{Tooltip[g1[x], "f(\[Eta]\[NotEqual]0)=f(\[Eta]=0)"],
> Tooltip[g2[x],
> "(\!\(\*SuperscriptBox[\"d\", \"2\"]\)f/\!\(\*SuperscriptBox[\"d\
> \[Eta]\", \"2\"]\)\!\(\*SubscriptBox[\")\",
> RowBox[{\"\[Eta]\", \"\[NotEqual]\", \"0\"}]]\)=0"],
> Tooltip[g3[x],
> "(\!\(\*SuperscriptBox[\"d\", \"2\"]\)f/\!\(\*SuperscriptBox[\"d\
> \[Eta]\", \"2\"]\)\!\(\*SubscriptBox[\")\",
> RowBox[{\"\[Eta]\", \"=\", \"0\"}]]\)=0"]}, {x, -4, 2},
> PlotRange -> {{-4, 2}, {-2, 3}}, PlotStyle -> Thick, Axes -> True,
> Ticks -> None, AxesLabel -> {\[Beta], \[Alpha]},
> LabelStyle -> Directive[Large], ImageSize -> 350,
> Epilog -> {Inset[
> Text[Style["\[Eta]=0", FontSize -> 20]], {1.5, 2.5}],
> Inset[Text[
> Style["\[Eta]\[NotEqual]0", FontSize -> 20]], {-1, -1.5}] },
> Filling -> {2 -> {3}},
> PlotLabel -> Style["Phase Diagram", 20, Red, Bold]];
>
>
> MainPart =
> DynamicModule[{pt = {1.7, 2}},
> GraphicsColumn[{Show[{pl, Graphics[Locator[Dynamic[pt]]]},
> ImageSize -> 500],
> GraphicsRow[{Dynamic[
> Plot[pt[[2]] x^2/2 + pt[[1]] x^4/4 + x^6/6, {x, -3, 3},
> PlotRange -> {{-4, 4}, {-2, 3}}, Axes -> True, Ticks -> None,
> AxesLabel -> {Style[\[Eta], Large, Plain,
> FontFamily -> "Symbol"],
> Style["f", Large, Italic, FontFamily -> "Times New Roman"]},
> PlotStyle -> {Thick, Blue}, LabelStyle -> Directive[Large],
> PlotLabel -> Style["Landau Potential", 20, Red, Bold] (*,
> ImageSize->400*)]],
> Dynamic[Plot[
> Tooltip[eta[t, pt[[1]]], "\!\(\*SqrtBox[FractionBox[
> RowBox[{
> RowBox[{\"-\", \"\[Beta]\"}], \"+\", SqrtBox[
> RowBox[{SuperscriptBox[\"\[Beta]\", \"2\"], \"-\",
> RowBox[{\"4\", \"\[Alpha]\[Gamma]\"}]}]]}],
> RowBox[{\"2\", \"\[Gamma]\"}]]]\)"], {t, pt[[2]] + 1, 3.2},
> PlotRange -> {{0, 3}, {0, 2.5}},(*ImageSize->400,*)
> PlotStyle -> {Thick, Blue}, Ticks -> None, Axes -> True,
> AxesLabel -> {T, \[Eta]},
> PlotLabel -> Style["Order Parameter", 20, Red, Bold],
> LabelStyle -> Directive[Large]]]}, ImageSize -> 700,
> Spacings -> 70]}, Spacings -> -350]]
>
>
> Regards, Alexei