【问题标题】:Interpolation/smoothing in Mathematica using Graphics使用图形在 Mathematica 中进行插值/平滑
【发布时间】:2011-07-16 18:22:56
【问题描述】:

我正在尝试平滑我在点之间绘制的路径。

请考虑:

 lesPoints = {{41, 26}, {42, 29}, {41, 31}, {46, 30}, {48, 30}, 
              {40, 30}, {43, 30}, {47, 30}, {48, 26}, {47, 20}}

这些是我用来追踪时间路径的真实注视坐标。

这就是我现在绘制它们的方式:

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]]]}]

我在尝试使用插值时没有做对。

这会是一个让道路平坦的好方法吗?还有什么替代方法?

【问题讨论】:

    标签: graphics wolfram-mathematica interpolation


    【解决方案1】:

    这样的事情呢

    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]}]]
    

    然后路径变成类似

    plot = ParametricPlot[interpolation[t], {t, 1, Length[lesPoints]}];
    Show[plot, Graphics[{Red, PointSize[0.02], Point /@ lesPoints}], Axes -> False]
    

    结果:

    【讨论】:

    • 感谢您的回答。我稍微开放一下,看看其他专家是否受到启发,但它解决了我的问题!
    【解决方案2】:

    这是另一种方式:

    Show[Graphics[{Red, PointSize[0.02], Point /@ lesPoints}], 
         ListLinePlot[lesPoints, InterpolationOrder -> 4]]
    

    编辑

    也(更简单)

    ListLinePlot[lesPoints, InterpolationOrder -> 4, Mesh -> Full,  Axes -> None]
    

    编辑

    使用this beautiful package可以得到:

    Show[Graphics[{Red, PointSize[0.015], Point /@ lesPoints}], 
     ListLinePlot[lesPoints, InterpolationOrder -> 4, Oriented     -> True, 
                                                      HowManyArrows -> 5]]
    

    编辑

    最后一个:)

    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}]]
    

    【讨论】:

    • @500 如果你有位置和时间,你也可以制作动画!
    • 哇,谢谢你。我有时间,绝对想实现那些美丽的路径!我必须说我现在很困惑,我想我需要修改我构建眼动分析主程序的方式,我不使用 Show Function 并将所有内容都放在 1 big Graphics 中。这造成了麻烦,我只在使用某些绘图功能时解决暂时静音问题。在这里,那些钟声再次响起。
    • 我在那里上传了最新版本的笔记本:laeh500.com/LAEH/Mathematica.html。我只打开了相关部分,您将在其中看到大型 Manipulate/Graphics。请让我知道您是否有机会查看是否有明显的您认为我应该做或不做的事情,以便在 Manipulate 中使用 Plot 和 Graphics。那会有很大帮助。我觉得现在是时候考虑一​​下我的效率了 :) 感谢您的关注。
    • @500 我下载了你的nb,但是太大了!抱歉,我没有时间阅读它(也没有能力快速阅读)。如果您对某件事有任何疑问,如果时间允许,我可以尝试检查一下。
    • 谢谢。我会尽量把问题简单化,然后问你。无论如何,这是这个论坛的最大好处之一!通常,在抽象出一个问题来提出一个问题时,我会在途中解决它!
    猜你喜欢
    • 2013-08-25
    • 1970-01-01
    • 1970-01-01
    • 2020-01-28
    • 2019-02-04
    • 1970-01-01
    • 2016-02-29
    • 2014-03-14
    • 2011-09-22
    相关资源
    最近更新 更多