# Drawing a Line and a Point inside a Cube

I am trying to draw a line (in a 3D box, so I can see all coordinates of that line) and, additionally, a point, to see how close that point is to that line.
With the code below, I can draw a line perfectly, but somehow the point only appears when the coordinates are positive (e.g. (“gP->SetPoint(0, 1.0, 0.0, 0.0);”). When I put the point at X = -1, the point does not appear anymore. Why is that?

Best regards,

Machiel

``````Main()
{
c1 = new TCanvas("c1","",500,500);

double xarr[2], yarr[2], zarr[2];

xarr[0] = -4; yarr[0] = -4; zarr[0] = -4;
xarr[1] =  4; yarr[1] =  4; zarr[1] =  4;

TGraph2D* g = new TGraph2D(2, xarr, yarr, zarr);
g->SetName("line");
g->SetLineColor(kBlue);
g->Draw("LINE");

TGraph2D* gP = new TGraph2D(1);
gP->SetName("point");
gP->SetPoint(0, -1.0, 0.0, 0.0);
gP->SetMarkerColor(kRed);
gP->SetMarkerStyle(21);
gP->SetMarkerSize(2);
gP->Draw("P SAME");
}``````

TGraph2D does not work with one point only.
To draw one point try to use TPolyMarker3D

Thank you very much. This works.

To be complete, the TGraph2D class is closely linked to the Delaunay triangulation. So even 2 points is not good. We need at least 3 to make one triangle.