2
$\begingroup$

This is half of a leaf:

y = Table[(1.1)^73 ((j - 1)/149), {j, 150}];
x1to45 = Table[(1 + 0.1/1.5 (1 - ((45 - j)/(45 - 1))^2.5))^73, {j, 
45}];
x46to150 = Table[(1 + 0.1/1.5 (1 - ((j - 45)/(150 - 45))^2.5))^73, {j, 46, 
150}];
x = Join[x1to45, x46to150];
xy = ListLinePlot[Transpose[Flatten /@ {x, y}]]

I need to graph the entire leaf. I tried it as follows:

nx1to45 = Table[2 - (1 + 0.1/1.5 (1 - ((45 -   j)/(45 - 1))^2.5))^73, {j, 45}];
nx46to150 = Table[2 - (1 + 0.1/1.5 (1 - ((j - 45)/(150 - 45))^2.5))^73, {j, 46, 
150}];
nx = Join[nx1to45, nx46to150];
nxy = ListLinePlot[Transpose[Flatten /@ {nx, y}]];
Show[{xy, nxy}, AspectRatio -> Automatic]

I appreciate any help to see the full leaf.

$\endgroup$
3
$\begingroup$

You can use

Show[{xy, nxy}, AspectRatio -> Automatic, PlotRange -> All]

or use a single ListLinePlot

ListLinePlot[Join@@(Transpose[Flatten /@ {# x, y}] & /@ {1, -1}), AspectRatio -> Automatic]

or use GeometricTransformation[#, ReflectionTransform[{0, -1}] on xy and Show it with xy:

Show[xy, MapAt[GeometricTransformation[#, ReflectionTransform[{-1, 0}]] &, xy, {1}], 
  AspectRatio -> Automatic, PlotRange -> All]

or plot input data for xy with the option ScalingFunctions -> {"Reverse", None} and combine the two plots:

Show[ListLinePlot[Transpose[Flatten /@ {x, y}], ScalingFunctions -> {#, None}]& /@
   {Identity, "Reverse"}, 
 PlotRange -> All, AspectRatio -> Automatic]

All four approaches give

enter image description here

Update: To get filling we need to plot the {y, x} pairs with the option Filling -> Axis and then use RotationTransform on the resulting graphics:

llp = ListLinePlot[Join @@ (Transpose[Flatten /@ {y, # x}] & /@ {1, -1}), 
    AspectRatio -> Automatic, Filling -> Axis, FillingStyle -> Yellow]

enter image description here

Apply RotationTransform to llp:

Show[MapAt[GeometricTransformation[#, RotationTransform[90 Degree]] &, llp, {1}], 
  PlotRange -> All, AspectRatio -> Automatic]

enter image description here

Update 2: how can I remove the middle line?

llp = ListLinePlot[Transpose[Flatten /@ {y, # x}] & /@ {1, -1}, 
  Axes -> False, PlotStyle -> Gray, AspectRatio -> Automatic, 
  Filling -> Axis, FillingStyle -> Yellow]; 
Show[MapAt[GeometricTransformation[#, RotationTransform[90 Degree]] &, llp, {1}], 
 PlotRange -> All, AspectRatio -> Automatic,  Axes -> False]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ How can I change color? I tried with FillingStyle -> Yellow $\endgroup$ – edwards Aug 30 '19 at 4:39
  • $\begingroup$ @edwards, please see the update. $\endgroup$ – kglr Aug 30 '19 at 4:53
  • $\begingroup$ To the last figure, how can I remove the middle line? I use axes -> false but it's still there. I would like the leaf alone, without any axis. $\endgroup$ – edwards Sep 17 '19 at 2:20
  • $\begingroup$ @edwards, remove Join@@ and add PlotStyle->Gray in definition of llp. $\endgroup$ – kglr Sep 17 '19 at 16:25
  • $\begingroup$ you can also use llp2 = ListLinePlot[Transpose[Flatten /@ {y, # x}] & /@ {1, -1}, Axes -> False, PlotStyle -> Gray, AspectRatio -> Automatic, Filling -> {1 -> {2}}, FillingStyle -> Yellow]; Show[MapAt[GeometricTransformation[#, RotationTransform[90 Degree]] &, llp2, {1}], PlotRange -> All, AspectRatio -> Automatic, Axes -> False] $\endgroup$ – kglr Sep 17 '19 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.