这是 (IMO) 基于使用 DisplayFunction 选项的贝利撒留代码的更优雅的方法(请参阅 here 关于此选项的有趣讨论):
Plot[Evaluate[Table[BesselJ[n, x], {n, 4}]], {x, 0, 10},
Filling -> Axis,
DisplayFunction ->
Function[{plot},
Show[plot,
AxesOrigin ->
First /@ (PlotRange /. AbsoluteOptions[plot, PlotRange]),
DisplayFunction -> Identity]]]
这两种方法的唯一缺点是AbsoluteOptions does not always give correct value of PlotRange。解决方案是使用the Ticks hack(它给出了完整的PlotRange,并添加了PlotRangePadding的显式值):
completePlotRange[plot_] :=
Last@Last@
Reap[Rasterize[
Show[plot, Ticks -> (Sow[{##}] &), DisplayFunction -> Identity],
ImageResolution -> 1]]
Plot[Evaluate[Table[BesselJ[n, x], {n, 4}]], {x, 0, 10},
Filling -> Axis,
DisplayFunction ->
Function[{plot},
Show[plot, AxesOrigin -> First /@ completePlotRange[plot],
DisplayFunction -> Identity]]]
有趣的是,这段代码给出的渲染与简单地指定 Frame -> {{Automatic, None}, {Automatic, None}}, Axes -> False 完全相同:
pl1 = Plot[Evaluate[Table[BesselJ[n, x], {n, 4}]], {x, 0, 10},
Filling -> Axis,
DisplayFunction ->
Function[{plot},
Show[plot, AxesOrigin -> First /@ completePlotRange[plot],
DisplayFunction -> Identity]]];
pl2 = Plot[Evaluate[Table[BesselJ[n, x], {n, 4}]], {x, 0, 10},
Filling -> Axis, Frame -> {{Automatic, None}, {Automatic, None}},
Axes -> False];
Rasterize[pl1] == Rasterize[pl1]
=> True