我正在使用Mathematica中的ListPlot绘制数据表。我注意到图中有一些渐近线,我不希望它被绘制(即曲线之间的直线)。我该怎么做才能删除直线?
答案 0 :(得分:3)
也许:
t = Table[Tan[i], {i, -Pi, Pi, .01}];
ListPlot[#, Joined -> True] & /@ {t, t /. x_ /; Abs@x > 10 -> None}
修改强>
更强大:
t = Table[Tan[i], {i, -Pi, Pi, .01}];
ao = AbsoluteOptions[ListPlot[t, Joined -> True],PlotRange]/. {_ -> {_,x_}} ->x;
ListPlot[t /. x_ /; (x < ao[[1]] || x > ao[[2]]) -> None, Joined -> True]
答案 1 :(得分:3)
Mark McClure在此发布的一种方法:How to annotate multiple datasets in ListPlots
t = Table[Tan[i], {i, -Pi, Pi, .01}];
plot = ListLinePlot[t];
DeleteCases[plot, Line[_?(Length[#] < 4 &)], Infinity]
答案 2 :(得分:0)
t = Table[Tan[i], {i, -Pi, Pi, .01}];
plot = ListLinePlot[t];
使用Position
Position[plot, Line[___], Infinity]
{{1,1,3,2},{1,1,3,3},{1,1,3,4},{1,1,3,5},{1,1,3 ,6}}
使用Part
:
plot[[1, 1, 3, 5 ;; 6]] = Sequence[]; Show[plot]