Message Boards Message Boards

Find intersection points of lines using ListPlot?

Anonymous User
Anonymous User
Posted 6 years ago

Hello, I am trying to find the intersection points of the two horizontal solid lined with the dashed line. I would like to label each point as for example point a and the second point as b. I would also like to display the value of the intersecting point. Note that I am aiming to find the x value of the intersecting point since I know y. I find it easier with function and using Plot function. I tried with this one but it didn't work. Thank you

list1 = {0, 1};
list2 = {0, 5};
ListLinePlot[Transpose[{list1, list2}], PlotStyle -> {Thick, Dashed}, 
 PlotRange -> {{0, 5}, {0, 5}}, 
 GridLines -> {None, {{2, {Black, Thick}}, {4, {Green, Thick}}}}]
POSTED BY: Anonymous User
2 Replies

Hi Joseph,

I hope this will help !

list1 = {0, 1};
list2 = {0, 5};
ListLinePlot[Transpose[{list1, list2}]
 , plot = PlotStyle -> {Thick, Dashed}
 , PlotRange -> {{0, 5}, {0, 5}}
 , GridLines -> {None, {{2, {Black, Thick}}, {4, {Green, Thick}}}}
 , Mesh -> {{2, 4}}
 , MeshFunctions -> {#2 &}
 , MeshStyle -> Directive[Red, PointSize[0.03]]
 ]

enter image description here

lst1 = Table[i, {i, {2, 2, 2, 2, 2}}];
lst2 = Table[i, {i, {4, 4, 4, 4, 4}}];
lst3 = Table[x, {x, {0, 5}}];
plot = ListLinePlot[{lst1, lst2, lst3}
  , PlotRange -> {{1, 5}, {0, 5}}
  ]
a = Graphics`Mesh`FindIntersections@plot
Length[a]

enter image description here

Regards,....Jos

POSTED BY: Jos Klaps
Anonymous User
Anonymous User
Posted 6 years ago

That was very helpful. Thank you Jos

POSTED BY: Anonymous User
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract