Sometimes shorter is clearer but at some point shorter is less clear.
First you can combine the two plots into one. Normally Show[plot1, plot2]
takes some characteristics from plot1
and ignores any differences in plot2
, most notably PlotRange
. If the plot range of plot1
does not contain the range of plot2
, then plot2
will be cut off. The workaround is to add an explicit PlotRange
option to Show
. With a single combine ParametricPlot[..]
, the plot range will be computed for all the functions. Normally that means asymptotes and large spike are truncated, which in many cases is seen as a benefit of PlotRange -> Automatic
over PlotRange -> All
.
ParametricPlot[
Join[
Table[u[j],
{j, Min[Im@z1, Im@z2], Max[Im@z1, Im@z2]}],
Table[v[j],
{j, Min[Re@z1, Re@z2], Max[Re@z1, Re@z2]}]],
{t, 0, 1}, Evaluated -> True]
From here it's not clear whether there are any significant improvements. The Min
, Max
, Re
, Im
can be restructured, but it's not clear to me that everyone would agree it's so much better that it's worth. I'll show them anyway, since they might be interesting. A standard change, the preference for which depends one's programming style, is to replace Table
with Map
. Another thing that seems an improvement is CoordinateBoundingBox
, which simplifies all the Min
, Max
, Re
, Im
stuff; but using its result is more complicated. Perhaps some will like it and others will think it's at best a wash.
Each of the following is to replace the first argument of ParametricPlot
:
(* Map (/@) instead of Table *)
Join[
u /@ Range[Min[Im@z1, Im@z2], Max[Im@z1, Im@z2]],
v /@ Range[Min[Re@z1, Re@z2], Max[Re@z1, Re@z2]]
]
(* CoordinateBoundingBox *)
Join @@ MapThread[#1 /@ Range @@ #2 &,
{{u, v},
Transpose@CoordinateBoundingBox[ReIm@{z1, z2}]}
]
(* The height of obfuscation *)
Join @@ MapThread[Map,
{{u, v},
Range @@@ Transpose@CoordinateBoundingBox[ReIm@{z1, z2}]}
]
If u
and v
are Listable
, then we can do better (or worse):
Join @@ {u@#1, v@#2} & @@
Range @@@ Transpose@CoordinateBoundingBox@ReIm@{z1, z2}
Numerical example:
Block[{z1 = 1 + 2 I, z2 = 5 - 3 I},
Join @@ MapThread[Map,
{{u, v},
foo = Range @@@ Transpose@CoordinateBoundingBox[ReIm@{z1, z2}]}
]
]
(* {u[1], u[2], u[3], u[4], u[5], v[-3], v[-2], v[-1], v[0], v[1], v[2]} *)
foo
(* {{1, 2, 3, 4, 5}, {-3, -2, -1, 0, 1, 2}} *)
We saved the intermediate result of Range @@@...
in foo
just to show what that piece of code does.