500*_*500 3 graphics interpolation wolfram-mathematica
我试图平滑我在点之间绘制的路径.
请考虑 :
lesPoints = {{41, 26}, {42, 29}, {41, 31}, {46, 30}, {48, 30},
{40, 30}, {43, 30}, {47, 30}, {48, 26}, {47, 20}}
Run Code Online (Sandbox Code Playgroud)
这些是我用来追踪时间路径的真实眼睛固定坐标.
这是我现在绘制它们的方式:
Graphics[{
Table[Arrow[{lesPoints[[i]], lesPoints[[i + 1]]}],
{i,Length[lesPoints] - 1}],
MapThread[Text[Style[#1, Large, FontFamily -> "Impact"], {#2, #3}] &,
PrependTo[Transpose[lesPoints], Range[1, Length@lesPoints]]]}]
Run Code Online (Sandbox Code Playgroud)
在尝试使用插值时,我无法做任何事情.
它是一条平滑路径的好方法,还有什么选择呢?
这样的事情呢
lesPoints = {{41, 26}, {42, 29}, {41, 31}, {46, 30}, {48, 30},
{40, 30}, {43, 30}, {47, 30}, {48, 26}, {47, 20}}
interpolation = Interpolation[Table[{i, lesPoints[[i]]}, {i, Length[lesPoints]}]]
Run Code Online (Sandbox Code Playgroud)
然后路径变得类似
plot = ParametricPlot[interpolation[t], {t, 1, Length[lesPoints]}];
Show[plot, Graphics[{Red, PointSize[0.02], Point /@ lesPoints}], Axes -> False]
Run Code Online (Sandbox Code Playgroud)
结果:
这是另一种方式:
Show[Graphics[{Red, PointSize[0.02], Point /@ lesPoints}],
ListLinePlot[lesPoints, InterpolationOrder -> 4]]
Run Code Online (Sandbox Code Playgroud)
编辑
还(更容易)
ListLinePlot[lesPoints, InterpolationOrder -> 4, Mesh -> Full, Axes -> None]
Run Code Online (Sandbox Code Playgroud)
编辑
通过使用这个美丽的包你可以得到:
Show[Graphics[{Red, PointSize[0.015], Point /@ lesPoints}],
ListLinePlot[lesPoints, InterpolationOrder -> 4, Oriented -> True,
HowManyArrows -> 5]]
Run Code Online (Sandbox Code Playgroud)
编辑
最后一个 :)
Show[
ListLinePlot[
lesPoints, InterpolationOrder -> 4,
Epilog -> (MapIndexed[Inset[Style[Text@First@#2, Medium], #1 + {-.2, .4}] &,
lesPoints]),
PlotRangePadding -> 1, Oriented -> True, Axes -> False,
PlotStyle -> Directive[Arrowheads[.015]]],
Graphics[{Red, PointSize[0.008], Point /@ lesPoints}]]
Run Code Online (Sandbox Code Playgroud)