Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Difference in Plots in Mathematica 4.0 and 5.0' topicStudent Support Forum > General > Archives > "Difference in Plots in Mathematica 4.0 and 5.0"

Next Comment >Help | Reply To Topic
Author Comment/Response
Gaurav
09/13/04 12:56pm

Hello,
I have a code(see below) which gives perfect plots in Mathematica 4.0 , but in Mathematica 5.0 , a small portion on the left is cut off. Can anyone help me out with this. Thanks in advance.
Gaurav

drawtext[s_, {x_, y_}, align_, opts___] := (xmin = Min[xmin,
x]; xmax = Max[xmax, x];
ymin = Min[ymin, y]; ymax = Max[ymax, x];
Text[s, {x, y}, align, opts])

buildtree[{
f_Real, t_},
h_, _, x_, y_, g_,
n_, offset_, opts___] := {drawtext[NumberForm[f, n], {x, y} +
offset[{0, -h(g/2)}], offset[{0, -2h g}], opts]}

buildtree[{f_,
t_}, h_, _, x_, y_, g_, n_, offset_, opts___] := {drawtext[f, {x,
y} + offset[{0, -h(g/2)}], offset[{0, -h g}], opts]}

buildtree[{f_, t_, {args___}}, h_, w_, x_, y_, g_, n_,
offset_, opts___] := Module[{nx, ny, nw}, nw = w/Length[{args}];
{nx, ny} = {x, y} + offset[{-w/2 - nw/2, h}];
Flatten[{Map[{Line[{{x, y}, AddTo[{nx, ny}, offset[{nw, 0}]] +
offset[{0, -g h}]}], buildtree[#, h, nw, nx, ny, g, n,
offset, opts]} &, {args}], drawtext[f, {x, y} +
offset[{0, -h(g/2)}], {0, 0}, opts]}]]

PlotGenome::orient = "Only \"Horizontal\" and \"Vertical\"
are valid values of option TreeOrientation.";
PlotGenome::root = "Option RootPosition -> `` does
not evaluate to either 1 or -1.";
PlotGenome::precision = "Option NodePrecision -> `` does not
evaluate to a positive integer.";
PlotGenome::space = "Option NodeSpacing -> `` does not evaluate to a number \
between 0 and 1.";

Options[PlotGenome] = {TreeOrientation -> "Vertical",
RootPosition -> 1, TextStyle -> {FontFamily -> "Ariel", FontWeight -> \
"Bold", FontSize -> 10}, NodeBackground -> Automatic, NodePrecision -> 2, \
NodeSpacing -> 0, NodeSubstitutions -> {GreaterEqual -> "
≥", Greater -> ">", LessEqual -> "≤", Less -> "<", Times -> "",
Divide -> "", Plus -> "+", Subtract -> "-"}};

PlotGenome[
Genome[{f_, t_}], opts___?OptionQ] := PlotGenome[
Genome[{f, t, {noArguments}}], opts]

PlotGenome[Genome[{f_, t_, {args___}}],
opts___?OptionQ] := Module[{$RecursionLimit = Infinity},
Module[{orient, offset, root, style, subst, color, genome, h, g, n,
gropts, txtopts, tree, s =
0.05}, If[! checkoptions[PlotGenome::badopt, Join[
Options[PlotGenome], Options[Graphics]], opts], Return[$Failed]];
orient = TreeOrientation /. {opts} /. Options[PlotGenome];
Switch[orient, "Vertical", offset =
Identity, "Horizontal", offset = Reverse, _, Message[
PlotGenome::orient, orient]; Return[$Failed]];
root = RootPosition /. {opts} /. Options[PlotGenome];
If[(root ≠ 1) && (root ≠ -1), Message[PlotGenome::
root, root]; Return[$Failed]];
h = root*First[offset[{-1, 1}]];
style = TextStyle /. {opts} /. Options[PlotGenome];
color = NodeBackground /. {opts} /. Options[PlotGenome];
subst = NodeSubstitutions /. {opts} /. Options[PlotGenome];
g = NodeSpacing /. {opts} /. Options[PlotGenome];
If[Not[((Head[g] == Real) || (Head[g] ==
Integer)) && (g ≥ 0) && (g < 1)], Message[PlotGenome::
space, g]; Return[$Failed]];
n = NodePrecision /. {opts} /. Options[PlotGenome];
If[Not[(Head[n] == Integer) && (n > 0)], Message[
PlotGenome::precision, n]; Return[$Failed]];
gropts = filteroptions[Graphics, opts];
txtopts = Sequence @@ {Background -> color, filteroptions[Text, opts]};
genome = If[args === noArguments, {f, t}, {f, t, {args}}] /. subst;
xmin = xmax = ymin = ymax = 0;
tree = buildtree[genome, h, 1, 0, 0, g, n, offset, txtopts];
Show[Graphics[tree], TextStyle -> style, gropts,
PlotRegion -> {{s, 1 - s}, {s, 1 - s}}]]]


URL: ,

Subject (listing for 'Difference in Plots in Mathematica 4.0 and 5.0')
Author Date Posted
Difference in Plots in Mathematica 4.0 and 5.0 Gaurav 09/13/04 12:56pm
Re: Difference in Plots in Mathematica 4.0 and ... Forum Modera... 09/15/04 10:10am
Re: Difference in Plots in Mathematica 4.0 and ... Gaurav 09/16/04 2:05pm
Second File Chapter 3.nb Gaurav 09/16/04 2:06pm
Next Comment >Help | Reply To Topic