I am plotting a table of data using ListPlot in Mathematica. I notice that there are a few asymptotes on the graph which I do not want it to be plotted (i.e. the straight lines between the curves). What should I do to remove the straight lines?
Asked
Active
Viewed 828 times
3
-
6Can you give an example dataset you're plotting? – Brett Champion Dec 09 '11 at 03:33
-
1Are you sure that you're talking about asymptotes? I have the impression that you're talking about gaps in your data. Asymptotes aeren't "straight lines between curves" – Sjoerd C. de Vries Dec 09 '11 at 06:31
-
2Perhaps [this](http://stackoverflow.com/q/4382610/499167) SO question is of interest? – 681234 Dec 09 '11 at 09:30
3 Answers
3
Perhaps:
t = Table[Tan[i], {i, -Pi, Pi, .01}];
ListPlot[#, Joined -> True] & /@ {t, t /. x_ /; Abs@x > 10 -> None}
Edit
More robust:
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]

Dr. belisarius
- 60,527
- 15
- 115
- 190
3
A method from Mark McClure's post here: How to annotate multiple datasets in ListPlots
t = Table[Tan[i], {i, -Pi, Pi, .01}];
plot = ListLinePlot[t];
DeleteCases[plot, Line[_?(Length[#] < 4 &)], Infinity]

Community
- 1
- 1

Chris Degnen
- 8,443
- 2
- 23
- 40
-
-
1@belisarius: ["ListLinePlot is a special case of ListPlot"](http://reference.wolfram.com/mathematica/ref/ListLinePlot.html#528126457) – Simon Dec 09 '11 at 13:55
-
@Simon May be, but the posted solution does not work with ListPlot in _my_ machine – Dr. belisarius Dec 09 '11 at 14:11
0
t = Table[Tan[i], {i, -Pi, Pi, .01}];
plot = ListLinePlot[t];
Using 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}}
Using Part
:
plot[[1, 1, 3, 5 ;; 6]] = Sequence[]; Show[plot]

681234
- 4,214
- 2
- 35
- 42