Skip to main content
added 32 characters in body
Source Link
kglr
  • 403.4k
  • 18
  • 501
  • 959
list = {{0, 0, 1}, {1, 1, 1}, {2, 4, 1}, {3, 2, -1}, {4, 1, -1}, {5, 4, 1}}; 

1. You can Partition the input list to create separate lines and use the option PlotStyle to color pieces individually:

ListLinePlot[Partition[list[[All, ;; 2]], 2, 1], PlotStyle -> (Rest[list[[All, -1]]] /. {1 -> Green, -1 -> Blue}) ] 

enter image description here

2. You can use the options Mesh and MeshShading as follows:

ListLinePlot[list[[All,split {1,= 2}]]SplitBy[list, Last];  Meshmesh ->= {Flatten@Position[Unitize[Differences[list[[Allsplit[[All, -1]]]]1, 1]1]]; meshshading -=split[[All, 1},   -1]] MeshShading/. {1 -> RotateRight[{Green, -1 -> Blue}; ListLinePlot[list[[All, {1, 2}]], Mesh -> UnitStep[list[[1{mesh}, MeshShading -1]]]]]> meshshading] 

enter image description here

list = {{0, 0, 1}, {1, 1, 1}, {2, 4, 1}, {3, 2, -1}, {4, 1, -1}, {5, 4, 1}}; 

1. You can Partition the input list to create separate lines and use the option PlotStyle to color pieces individually:

ListLinePlot[Partition[list[[All, ;; 2]], 2, 1], PlotStyle -> (Rest[list[[All, -1]]] /. {1 -> Green, -1 -> Blue}) ] 

enter image description here

2. You can use the options Mesh and MeshShading as follows:

ListLinePlot[list[[All, {1, 2}]],  Mesh -> {Flatten@Position[Unitize[Differences[list[[All, -1]]]], 1] - 1},    MeshShading -> RotateRight[{Green, Blue}, 1 - UnitStep[list[[1, -1]]]]] 

enter image description here

list = {{0, 0, 1}, {1, 1, 1}, {2, 4, 1}, {3, 2, -1}, {4, 1, -1}, {5, 4, 1}}; 

1. You can Partition the input list to create separate lines and use the option PlotStyle to color pieces individually:

ListLinePlot[Partition[list[[All, ;; 2]], 2, 1], PlotStyle -> (Rest[list[[All, -1]]] /. {1 -> Green, -1 -> Blue}) ] 

enter image description here

2. You can use the options Mesh and MeshShading as follows:

split = SplitBy[list, Last]; mesh = split[[All, -1, 1]]; meshshading =split[[All, 1, -1]] /. {1 -> Green, -1 -> Blue}; ListLinePlot[list[[All, {1, 2}]], Mesh -> {mesh}, MeshShading -> meshshading] 

enter image description here

added 357 characters in body
Source Link
kglr
  • 403.4k
  • 18
  • 501
  • 959
list = {{0, 0, 1}, {1, 1, 1}, {2, 4, 1}, {3, 2, -1}, {4, 1, -1}, {5, 4, 1}}; 

1. You can Partition the input list to create separate lines and use the option PlotStyle to color pieces individually:

ListLinePlot[Partition[list[[All, ;; 2]], 2, 1], PlotStyle -> (Rest[list[[All, -1]]] /. {1 -> Green, -1 -> Blue}) ] 

enter image description here

2. You can use the options Mesh and MeshShading as follows:

ListLinePlot[list[[All, {1, 2}]], Mesh -> {Flatten@Position[Unitize[Differences[list[[All, -1]]]], 1] - 1}, MeshShading -> RotateRight[{Green, Blue}, 1 - UnitStep[list[[1, -1]]]]] 

enter image description here

list = {{0, 0, 1}, {1, 1, 1}, {2, 4, 1}, {3, 2, -1}, {4, 1, -1}, {5, 4, 1}}; 

You can use the options Mesh and MeshShading as follows:

ListLinePlot[list[[All, {1, 2}]], Mesh -> {Flatten@Position[Unitize[Differences[list[[All, -1]]]], 1] - 1}, MeshShading -> RotateRight[{Green, Blue}, 1 - UnitStep[list[[1, -1]]]]] 

enter image description here

list = {{0, 0, 1}, {1, 1, 1}, {2, 4, 1}, {3, 2, -1}, {4, 1, -1}, {5, 4, 1}}; 

1. You can Partition the input list to create separate lines and use the option PlotStyle to color pieces individually:

ListLinePlot[Partition[list[[All, ;; 2]], 2, 1], PlotStyle -> (Rest[list[[All, -1]]] /. {1 -> Green, -1 -> Blue}) ] 

enter image description here

2. You can use the options Mesh and MeshShading as follows:

ListLinePlot[list[[All, {1, 2}]], Mesh -> {Flatten@Position[Unitize[Differences[list[[All, -1]]]], 1] - 1}, MeshShading -> RotateRight[{Green, Blue}, 1 - UnitStep[list[[1, -1]]]]] 

enter image description here

Source Link
kglr
  • 403.4k
  • 18
  • 501
  • 959

list = {{0, 0, 1}, {1, 1, 1}, {2, 4, 1}, {3, 2, -1}, {4, 1, -1}, {5, 4, 1}}; 

You can use the options Mesh and MeshShading as follows:

ListLinePlot[list[[All, {1, 2}]], Mesh -> {Flatten@Position[Unitize[Differences[list[[All, -1]]]], 1] - 1}, MeshShading -> RotateRight[{Green, Blue}, 1 - UnitStep[list[[1, -1]]]]] 

enter image description here