3

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?

3
  • 6
    Can you give an example dataset you're plotting? Commented Dec 9, 2011 at 3:33
  • 1
    Are 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" Commented Dec 9, 2011 at 6:31
  • 2
    Perhaps this SO question is of interest? Commented Dec 9, 2011 at 9:30

3 Answers 3

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] 
Sign up to request clarification or add additional context in comments.

3 Comments

The OP asked for ListPlot, not ListLinePlot
@Simon May be, but the posted solution does not work with ListPlot in my machine
3

Perhaps:

t = Table[Tan[i], {i, -Pi, Pi, .01}]; ListPlot[#, Joined -> True] & /@ {t, t /. x_ /; Abs@x > 10 -> None} 

enter image description here

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] 

Comments

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] 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.