# Moving the position of the gray line in the plot

I have been making cantor type sets. I have the following code, how to lower the position of gray lines a bit so that I can see the intersection.

The code is:

cantorRule = Line[{{a_, n_}, {b_, n_}}] :> With[{d = b - a, np = n - 0.1},
{Line[{{a, np}, {a + (3 d)/4, np}}], Line[{{b - d/2, np}, {b, np}}]}
]
label = # /. l : Line[p : {{_, _}, {_, _}}] :> {l, Black, Text[Rationalize[#[[1]]], Offset[{0, -20}, #], {Center, Top}] & /@ p} &;
lines = Flatten@NestList[# /. cantorRule &, Line[{{0., 0}, {1., 0}}], 6];
coloredlines = Flatten[Riffle[{Black, Gray}, #] & /@ Partition[lines, 2, 2, {-1, 1}, {}]];
Graphics[{CapForm["Butt"], Thickness[.05], coloredlines}]

• I have removed your commented code. Feel free to put that back in if you want, but I assume that since it's commented, it's unnecessary to your question, and so it doesn't need to be included.) – march Aug 26 '19 at 17:43
• @march yes, sorry for that. How can I shift the grey lines bit down so that the intersection can be identified? – supremum Aug 26 '19 at 17:46

s = .02;
coloredlines = Riffle[{Black, Gray}, #] & /@ Partition[lines, 2, 2, {-1, 1}, {}];

coloredlines2 = MapAt[# /.  Line[{{a_, b_}, {c_, b_}}] :> Line[{{a, b - s}, {c, b - s}}] &,
coloredlines, {All, 3 ;;}];

Graphics[{CapForm["Butt"], Thickness[.05], coloredlines2}]


You can also use

coloredlines3 = MapAt[# /. l_Line :> Translate[l, {0, -s}]&, coloredlines, {All, 3 ;;}]
`