【发布时间】:2011-05-30 20:08:31
【问题描述】:
有没有办法将ListPlot 的图形与Plot 的图形结合起来? (我需要在 ListPlot 的图形上绘制一个函数的图形)
【问题讨论】:
-
Fit[ ]reference.wolfram.com/mathematica/ref/Fit.html的帮助中有很多很好的例子
有没有办法将ListPlot 的图形与Plot 的图形结合起来? (我需要在 ListPlot 的图形上绘制一个函数的图形)
【问题讨论】:
Fit[ ]reference.wolfram.com/mathematica/ref/Fit.html的帮助中有很多很好的例子
您可以将任何图形与Show 函数结合起来,如下所示:
Show[myListPlot, myPlot]
这概括为一次组合任意数量的图:Show[p1, p2, p3, p4, ...] 或 Show[{p1,p2,p3,p4,...}]
参考及图片来源:http://reference.wolfram.com/mathematica/ref/Show.html
如果Show 没有以正确的顺序堆叠图形,您也可以使用Epilog,但是将两个以上的图形与 Epilog 组合起来会很麻烦。
【讨论】:
Epilog 过于矫枉过正或者您所说的“堆叠顺序”是什么意思?
Epilog 来叠加图呢?一个例子是在Histogram 下的应用程序中。
从你的第二行,我认为Epilog 是你正在寻找的。这是一个例子:
f[x_] := 1/Sqrt[2 Pi] Exp[-(x^2)/2];
ListPlot[
Table[
{x, PDF[NormalDistribution[], x]}, {x, -4, 4, 0.1}
],
Epilog -> First@Plot[f[x], {x, -4, 4}, PlotStyle -> Red]
]
另一种方法是使用Show
p1 = ListPlot[
Table[
{x, PDF[NormalDistribution[], x]}, {x, -4, 4, 0.1}
]
];
p2 = Plot[f[x], {x, -4, 4}, PlotStyle -> Red];
Show[p1,p2]
另一方面,如果我弄错了,而您只是想将它们组合在一起,那么您可以使用GraphicsRow 或GraphicsColumn。
FullGraphics@GraphicsRow[{p1, p2}]
【讨论】: