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

Here is a sample data file

m = {{-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.

Now let's create a color code depending on the third integer element

getColor[m_List, i_Integer] := Module[{s = m[[i, 3]]},
Which[s == 0, Black, s == 1, Darker[Green], s == 2, Red, s == 3,
Blue, s == 4, Magenta, s == 5, Orange, s == 6, Cyan, s == 7,
Brown]];

And let's plot the color points on the x-axis

data = Table[{PointSize[0.001], getColor[m, i], Point[{m[[i, 1]], 0}]},
{i, 1, Length[m]}];
S0 = Graphics[data] The above plot does not correspond to the sample data but to the actual data file. Nevertheless we see that the colors are hardly visible since all points lie on the x-axis.

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$.

Any suggestions?

• Try Line? p.s. Which -> Switch will shorten your code here.
– Kuba
Dec 11 '15 at 10:36
• @Kuba You mean data = Table[{Thickness[0.001], getColor[m, i], Line[{{m[[i, 1]], -1}, {m[[i, 1]], 1}}]}, {i, 1, Length[m]}]; right? How can Which could be substituted with Which? Dec 11 '15 at 10:43

m = {{-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}};

colors = {Black, Darker[Green], Red, Blue, Magenta, Orange, Cyan, Brown};

data = Table[{colors[[m[[i, 3]]]], Line[{{m[[i, 1]], -1}, {m[[i, 1]], 1}}]}, {i, 1, Length[m]}];
S0 = Graphics[data] Or more compactly (you don't need Table):

Graphics[{colors[[#[]]], Line[{{#[], -1}, {#[], 1}}]} & /@ m]

EDIT for Jason B: