0
$\begingroup$

This question already has an answer here:

I want to plot a list of points where every point has a different colour. Is it also possible to label these points according to a list of sample names I have in Excel? Please help.

$\endgroup$

marked as duplicate by m_goldberg, MarcoB, user9660, Jens, ubpdqn Mar 13 '16 at 8:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Giving a different color to each point is not that hard, you can use Style, look at the help page for ListPlot and you find the example ListPlot[Table[ Style[{Cos[t], Sin[2 t]}, Hue[t/(2 Pi)]], {t, 0, 2 Pi, Pi/20}], PlotStyle -> PointSize[Medium]] $\endgroup$ – Jason B. Mar 11 '16 at 12:20
  • $\begingroup$ Thanks for your answer. I do find it difficult to apply it to my case though. I simply have an imported list of points from Excel that I would like to plot in Mathematica. $\endgroup$ – Sukanya Sengupta Mar 11 '16 at 13:56
1
$\begingroup$

ListPlot accepts a list of list of points, assigning new colours to each of the sublists.

points = Table[{{RandomReal[{1, 10}], RandomReal[{1, 10}]}}, {i, 1, 10}]

(* {{{1.54315, 3.96704}}, {{6.2341, 6.44874}}, {{1.88163, 
5.46795}}, {{2.37001, 7.649}}, {{6.74071, 3.67992}}, {{9.87758, 
4.82062}}, {{9.71256, 2.90955}}, {{2.53583, 6.80984}}, {{9.04613, 
1.49516}}, {{8.10797, 4.08785}}} *)

labels = Table["Dot " <> ToString[i], {i, 1, 10}]

ListPlot[points, PlotLegends -> labels]

gives

ListPlot example with multiple colours

$\endgroup$
  • $\begingroup$ Thanks for your answer! I formulated my imported dataset into the Table format you have here and then the rest worked perfectly for me. $\endgroup$ – Sukanya Sengupta Mar 11 '16 at 13:58
  • $\begingroup$ Any idea if I could have the labels next to each data point? By using PlotMarkers and Table command perhaps? $\endgroup$ – Sukanya Sengupta Mar 11 '16 at 14:01
  • $\begingroup$ Have a look here: mathematica.stackexchange.com/a/63570/19176 $\endgroup$ – Åsmund Hj Mar 11 '16 at 14:03
  • $\begingroup$ Perfect! Thanks a ton! :) $\endgroup$ – Sukanya Sengupta Mar 11 '16 at 14:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.