I have data set like this (x , y , n) n is the number from 0 to 12 I want to plot this data set but I want to the color of each point be base on the third column. For example if I have 0 in third column get red point on my graph and for 2 get blue and so far.
2 Answers
I assume your data consist of triplets: {x,y,color}. For an example, we create some data:
SeedRandom[10];
dat = RandomInteger[{0, 12}, {20, 3}];
We use ListPlot to display the data and color the points using ColorFunction. As ColorFunction only receive {x,y}, we need to look up the third element of the triple:
SeedRandom[10];
dat = RandomInteger[{0, 12}, {20, 3}];
ListPlot[dat[[All, 1 ;; 2]],
ColorFunction -> (Hue[Cases[N@dat, {#1, #2, _}][[1, 3]]/12] &),
ColorFunctionScaling -> False]
The data points in the x- and y-axes.
x = {1, 2, 3, 4};
y = {1, 2, 3, 4};
Create the list to be plotted
z = Thread[{x, y}]
One way:
ListPlot[{#} & /@ z, PlotStyle -> list2]
A second way:
ListPlot[{{Style[z[[1]], Green]}, {Style[z[[2]], Purple]}, {Style[
z[[3]], Red]}}, PlotStyle -> PointSize[0.02]]
A third way:
Graphics[Prepend[Riffle[list2, Point /@ list1], PointSize[0.03]],
Frame -> True]
x
a list andy
a list andn
just a number? or do you have a list of three lists? can you provide some data explicitly? $\endgroup$GathetBy[data,Last]
and plot the new data set. $\endgroup$