Assume there are three groups of 2-dimensional coordinates

data = RandomVariate[NormalDistribution[#, .25], {15, 2}] & /@ Range[3];

Is there a way to ListPlot these data points just like

ListPlot[data, PlotStyle -> {Red, Blue, Green}]

but instead of the dots with the result of an integer-valued function, e.g. Round[Norm[#]]&, shown in the according colour?

I already had a look at this and that question, but wasn't able to modify the answers to obtain the desired result.

  • 1
    $\begingroup$ you want numbers instead of the points? $\endgroup$ – rm -rf Aug 15 '12 at 16:41
  • $\begingroup$ Yes, each point should be the number resulting in applying to it a pre-defined function f:R^2 -> N in the colour as shown above. $\endgroup$ – Frederik Ziebell Aug 15 '12 at 16:48

Not sure if this is what you had in mind, but you could do something like

ListPlot[data, PlotStyle -> {Red, Green, Blue}] /. 
   {Point[a_] :> (Text[Round[Norm[#]], #] & /@ a)}

Mathematica graphics

  • $\begingroup$ I think there was a question by Mr.W in SO showing that the points aren't shown in their correct positions with this technique. If my memory does not fail, the trick was rasterizing the symbols before plotting. Mmm ... I should check $\endgroup$ – Dr. belisarius Aug 15 '12 at 16:59
  • $\begingroup$ @Verde I missed that question. If I superpose the original ListPlot on top of the one above, the numbers seem to be shifted slightly with respect to the dots by a few pixels. I wonder what causes this. $\endgroup$ – Heike Aug 15 '12 at 17:13
  • 1
    $\begingroup$ @Verde This is probably the question you're thinking of... $\endgroup$ – rm -rf Aug 15 '12 at 17:18

The numbers will confusingly overlap, especially with more precision shown. Just in case here is a solution with radius of disk reflecting the Norm and Tooltip showing the number?

Graphics[{Hue[RandomReal[], 1, 1, .4], 
    Map[Tooltip[Disk[#, .02 Norm[#]], Norm[#]] &, #]} & /@ data, Frame -> True]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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