0
$\begingroup$

I am doing 3-D scatter plot with labels and using the following code

data = {{0.879`, -0.093`, 0.08`}, {0.865`, 0.069`, -0.073`}, {0.863`, 
   0.086`, -0.144`}, {0.827`, -0.202`, 0.17`}, {0.768`, -0.233`, 
   0.127`}, {0.697`, 0.246`, 0.118`}, {0.691`, 
   0.306`, -0.276`}, {-0.641`, 0.316`, 0.541`}, {0.64`, -0.299`, 
   0.404`}, {0.058`, 0.869`, -0.014`}, {0.074`, 0.866`, 
   0.04`}, {-0.203`, 0.586`, 0.42`}, {-0.049`, 0.08`, 
   0.759`}, {0.174`, 0.02`, 0.723`}, {0.143`, -0.05`, 
   0.632`}, {-0.405`, 0.322`, 0.576`}}

labels = {{"Stylish"}, {"Fun"}, {"Exciting"}, {"Status"}, \
{"Performance"}, {"Powerful"}, {"Sports"}, {"Family"}, {"Luxurious"}, \
{"Outdoorsy"}, {"Rugged"}, {"Versatile"}, {"Safe"}, {"Comfortable"}, \
{"Dependable"}, {"Practical"}}

Show[Graphics3D[{Blue, PointSize[0.02], Point[data]}], 
 Graphics3D[Text[#[[1]], 1.04 *# & /@ data] & /@ labels], 
 Axes -> True, BoxRatios -> 1]

However, what I got is a graph with labels crushed together, as shown below enter image description here

I believe there is something wrong with this part of code 1.04 *# & /@ data. What should I do to make each label appear besides each corresponding point? Thank you.

$\endgroup$

closed as off-topic by xzczd, ciao, Karsten 7., bbgodfrey, Bob Hanlon Apr 15 '15 at 12:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – xzczd, ciao, Karsten 7., bbgodfrey, Bob Hanlon
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ Show[Graphics3D[{Blue, PointSize[0.02], Point[data]}], Graphics3D[ Text[#[[1, 1]], 1.04*#[[2]]] & /@ Transpose@{labels, data}], Axes -> True, BoxRatios -> 1] $\endgroup$ – xzczd Apr 15 '15 at 5:17
  • 1
    $\begingroup$ Debugging thing like this is easy if you just take the Text[...] /@ labels part and evaluate it in a cell of its own. $\endgroup$ – Sjoerd C. de Vries Apr 15 '15 at 6:35
2
$\begingroup$

You can replace Map with Thread.

Graphics3D[{{Blue, PointSize[0.02], Point[data]}, 
  Thread[Text[Flatten[labels], 1.04 data]]}, Axes -> True, 
 BoxRatios -> 1]

However I would sugest you to create third list, which would adjust label position. Something like (here chosen randomly)

labelsRelativePositions = 
 Table[{RandomInteger[{-1, 1}], 
   RandomInteger[{-1, 1}]}, {Length[data]}];

Graphics3D[{{Blue, PointSize[0.02], Point[data]}, 
  Thread[Text[Flatten[labels], 1.04 data, labelsRelativePositions]]}, 
 Axes -> True, BoxRatios -> 1]
$\endgroup$

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