有没有一种方法可以将ListPlot
的图形与Plot
的图形结合起来?(我需要在一个ListPlot的图形上绘制一个函数的图形)
有没有一种方法可以将ListPlot
的图形与Plot
的图形结合起来?(我需要在一个ListPlot的图形上绘制一个函数的图形)
你可以像下面这样使用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
组合超过2个图形会变得笨重。
Epilog
来叠加绘图呢?一个例子是在Histogram
下的应用程序中。 - user564376从你的第二行开始,我认为你要找的是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}]
Fit[]
的帮助文档中有许多好的例子,可供参考:http://reference.wolfram.com/mathematica/ref/Fit.html。 - Dr. belisarius