It is a question very easy, but I am confused how to use the Table
or Riffle
or Partition
to achieve this result.
data = {{0, 0}, {228.9, 0.06}, {313.7, 0.10}, {340.6, 0.14}, {355.1,
0.18}, {368.2, 0.22}};
lPlot = ListPlot[data, Joined -> True];
pt = Graphics[{Red, PointSize[0.02],
Point[Table[data[[#]] &[Range[Length[data]]], 1]]}];
lines = Graphics[{Dashed, Line[{{0, 0}, {0, 0}}],
Line[{{228.9, 0}, {228.9, 0.06}}],
Line[{{313.7, 0}, {313.7, 0.1}}],
Line[{{340.6, 0}, {340.6, 0.14}}],
Line[{{355.1, 0}, {355.1, 0.18}}],
Line[{{368.2, 0}, {368.2, 0.22}}]}];
Show[lPlot, pt, lines]
I got two tables, but I found it difficult to use them
p1Line = Partition[
Riffle[Flatten@Table[data[[#, 1]] &[Range[Length[data]]], 1],
Table[0, Length[data]]], 2]
p2Line = Partition[
Flatten[Table[data[[#]] &[Range[Length[data]]], 1]], 2]
Answer
Based on the comments of N.J.Evans
data = {{0, 0}, {228.9, 0.06}, {313.7, 0.10}, {340.6, 0.14}, {355.1,
0.18}, {368.2, 0.22}};
lPlot = ListPlot[data, Joined -> True];
pt = Graphics[{Red, PointSize[0.02],
Point[Table[data[[#]] &[Range[Length[data]]], 1]]}];
lines = Graphics[{
Dashed, Line[{{#1, 0}, {#1, #2}}] & @@@ data}];
Show[lPlot, pt, lines]
Comments
Post a Comment