1
$\begingroup$

I would like to plot points in 3D Space and show a number next to them.

How can I achieve this ?

Here is the list of coordinates / number :

(0 0 0)    //0
(35 0 0)   //1
(35 10 0)  //2
(0 10 0)   //3
(0 0 1)    //4
(35 0 1)   //5
(35 10 1)  //6
(0 10 1)   //7
(0 100 0)  //8
(35 100 0) //9
(0 100 1)  //10
(35 100 1) //11
(-20 0 0)  //12
(-20 0 1)  //13
(-20 10 0) //14
(-20 10 1) //15
(-20 100 0) //16
(-20 100 1) //17

In Mathematica Format:

corrd = {{0,0,0},{35,0,0},{35,10,0},{0,10,0},{0,0,1},{35,0,1},{35,10,1},{0,10,1},{0,100,0},{35,100,0},{0,100,1},{35,100,1},{-20,0,0},{-20,0,0},{-20,0,1},{-20,10,0},{-20,10,1},{-20,100,0},{-20,100,1}};

numb= Table[i,{i,0,17}];

I tryed ListPointPlot3D[corrd], but then I don't know how to show the number next to them ?

$\endgroup$
3
  • $\begingroup$ Possible duplicate: mathematica.stackexchange.com/questions/61850/… $\endgroup$ Commented May 13, 2017 at 18:00
  • $\begingroup$ numb = Table[i,{0,17}] cannot work. Try: numb = Range[{0,17}] $\endgroup$ Commented May 13, 2017 at 20:12
  • $\begingroup$ @DavidG.Stork thanks for spotting the typo. Corrected it. $\endgroup$ Commented May 14, 2017 at 8:52

3 Answers 3

1
$\begingroup$

You can let the numbers be the markers, i.e., there isn't necessarily a need for points. You might also want to Style the numbers to make them easier to read.

corrd = DeleteDuplicates[{
    {0, 0, 0}, {35, 0, 0}, {35, 10, 0}, {0, 10, 0},
    {0, 0, 1}, {35, 0, 1}, {35, 10, 1}, {0, 10, 1},
    {0, 100, 0}, {35, 100, 0}, {0, 100, 1}, {35, 100, 1},
    {-20, 0, 0}, {-20, 0, 0}, {-20, 0, 1}, {-20, 10, 0},
    {-20, 10, 1}, {-20, 100, 0}, {-20, 100, 1}}];

numb = Range[0, Length[corrd] - 1];

Graphics3D[
 Text[
    Style[
     ToString[#[[1]]],
     14,
     Bold,
     ColorData["TemperatureMap"][#[[2, 3]]]], #[[2]]] & /@
  Transpose[{numb, corrd}],
 BoxRatios -> {1, 1, 1/2},
 Axes -> True]

enter image description here

$\endgroup$
1
  • $\begingroup$ Wow. Thanks a lot ! This is a very nice solution. $\endgroup$ Commented May 13, 2017 at 19:34
2
$\begingroup$

You can just use Graphics3D. Something like this can be done without any styling:

numb = Range[19];

Graphics3D[MapThread[{Red, Text[#2, #1], Point[#1]} &, {corrd, numb}],
  Axes -> True, BoxRatios -> {1, 1, 0.5}]
$\endgroup$
1
  • $\begingroup$ Nice ! Thanks a lot ! $\endgroup$ Commented May 13, 2017 at 14:16
0
$\begingroup$

Using ListPointPlot3D:

corrd = {{0, 0, 0}, {35, 0, 0}, {35, 10, 0}, {0, 10, 0}, {0, 0, 
    1}, {35, 0, 1}, {35, 10, 1}, {0, 10, 1}, {0, 100, 0}, {35, 100, 
    0}, {0, 100, 1}, {35, 100, 1}, {-20, 0, 0}, {-20, 0, 
    1}, {-20, 10, 0}, {-20, 10, 1}, {-20, 100, 0}, {-20, 100, 1}};

numb = Range[0, Length[corrd] - 1];

ListPointPlot3D[corrd -> numb
, LabelingFunction -> Callout
,  Filling -> Axis
,FillingStyle->Red
,BoxRatios->{1,1,1/2}
,PlotRangePadding->Scaled[.15]
]

ListPointPlot3D demo


The reason I used the cloud account is that the output plot in v12.2.0 has a minor bug such that callouts are not properly rendered.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.