# Jumping from one dimension (1D) to two dimensions (2D) Part II

Here is a sample data file

data = {{-10,3,1},{-7.5,12,3},{-1.5,5,2},{2,4,4},{3,7,4},{6,9,5},{7,1,5},
{8,3,1},{9,12,2},{10,8,5}};


The first element of the list is a point on the x-axis, while the other two are integers for other information.

A color code regarding the second integer of the list

valrange = {0, 43};
data[[All, 2]] = Rescale[data[[All, 2]], valrange];
colfunc[x_, cf_] := If[(x[] == 0), White, ColorData[cf][1 - x[]]];

S0 = Graphics[{{PointSize[0.005]}, Point[{#[], 0}, VertexColors ->
colfunc[#, "DeepSeaColors"]] & /@data}] I would like the following: Get some height. In particular, for every color point $x_0$ to create a vertical line at $x_0$ with the same color let's say from $y_{min} = −1$ up to $y_{max} = 1$.

I tried

S0 = Graphics[{{Thickness[0.001]}, Line[{{#[], -1}, {#[], 1}},
VertexColors -> colfunc[#, "DeepSeaColors"]] & /@ data}]


but it does not work. All lines have black color.

Any suggestions?

• Graphics[{Thick, Line[{{0, 0}, {2, 1}}, VertexColors -> Red]}] – Kuba Dec 11 '15 at 13:06
• So provide at least two elements or don't use VertexColors but just put the color before line. p.s. when you have {Pointsize[_]} hidden inside a list, it won't affect anything. – Kuba Dec 11 '15 at 13:08
• @Kuba I don't quite understand your suggestion. I want shades of blue not specific colors. – Vaggelis_Z Dec 11 '15 at 13:10
• @Kuba Whan I evaluate Graphics[{Thick, Line[{{0, 0}, {2, 1}}, VertexColors -> Red]}] the line is black. – Vaggelis_Z Dec 11 '15 at 13:16
• Yes, the point of that code was - you are doing the same thing... – Kuba Dec 11 '15 at 15:08

Graphics[{Thickness[0.01],
Line[{{#[], -1}, {#[], 1}},
VertexColors -> colfunc[#, "DeepSeaColors"]] & /@ data}] /.
Rule[VertexColors, c_] :> VertexColors -> {c, c} Or, shorter

Graphics[{Thickness[0.01], Line[{{#[], -1}, {#[], 1}},
VertexColors -> {#, #} &[colfunc[#, "DeepSeaColors"]]] & /@ data}]

• It works like a charm! A quick question: why S0 = Graphics[{Thickness[0.001], Line[{{#[], -1}, {#[], 1}}, VertexColors -> colfunc[#, "DeepSeaColors"]] & /@ data}] does not work and we need an extra rule? – Vaggelis_Z Dec 11 '15 at 13:29
• By definition VertexColors  needs two color directives. VertexColors -> {Red, Blue} would blend between Red and Blue. So, if we want only one color we have to write VertexColors -> {Red, Red} – eldo Dec 11 '15 at 13:37