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?
- 6Can you give an example dataset you're plotting?Brett Champion– Brett Champion2011-12-09 03:33:28 +00:00Commented Dec 9, 2011 at 3: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– Sjoerd C. de Vries2011-12-09 06:31:27 +00:00Commented Dec 9, 2011 at 6:31
- 2Perhaps this SO question is of interest?681234– 6812342011-12-09 09:30:27 +00:00Commented Dec 9, 2011 at 9:30
Add a comment |
3 Answers
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] 3 Comments
Dr. belisarius
The OP asked for ListPlot, not ListLinePlot
Simon
@belisarius: "ListLinePlot is a special case of ListPlot"
Dr. belisarius
@Simon May be, but the posted solution does not work with ListPlot in my machine
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]