# How to remove vertical lines in ListLinePlot?

I am ploting electronic band structure in Mathematica using ListLinePlot. Like this

However I don't want those vertical Lines indicated by red circle.

I want to delete those vertical lines and get this feel

An idea maybe to post-process the plot and keep styles intact. But I got lost in the complicated FullForm of Plot.

A simple example to start is for example ListLinePlot[{{1, 1}, {2, 1}, {2, 2}, {3, 2}}, Frame -> True]

• ListLinePlot[ Split[{{1, 1}, {2, 1}, {2, 2}, {3, 2}}, First[#] != First[#2] &], Frame -> True]?
– kglr
Apr 11, 2017 at 11:52
• Possible duplicate: mathematica.stackexchange.com/questions/11714/… -- The post-processing methods of some answers should work, and kglr's solution shows how to do it with ListLinePlot. Apr 11, 2017 at 11:53
• Hi, @kglr. Thanks for your answer. The problem is that your method breaks one line into two line, and viewed as two colors. What if I want to visualize multiple lines Apr 11, 2017 at 13:46
• @matheorem, as you suggested post-processing is a way to keep the styles intact: ListLinePlot[{{1, 1}, {2, 1}, {2, 2}, {3, 2}}, Frame -> True] /. Line[x_] :> (Line /@ Split[x, First[#] != First[#2] &])
– kglr
Apr 11, 2017 at 14:03
• @kglr Works like a gem! Thank you so much! Apr 11, 2017 at 14:39

## 1 Answer

ClearAll[postProcess]
postProcess = # /. Line -> Function[{x}, Line /@ Split[x, First[#] != First[#2] &]] &;


Example:

llp = ListLinePlot[{{{1, 1}, {2, 1}, {2, 4}, {4, 4}}, {{1, 2}, {3,  2}, {3, 3}, {4, 3}}},
Frame -> True, PlotStyle -> {Directive[Red, Thick], Directive[Green, Thick]},
ImageSize -> 250];

Row[{llp, postProces@llp}, Spacer[10]]