Plotting a sphere with a TGraph2D

Promising!


First, There is a strange bounding box on the canvas that disappears when saving it as a png. Here is the screenshot prior to saving:

Secondly, are there any controls over the surface painting? I can still see through the sphere making it hard to tell where the intersection is.

import numpy as np
import ROOT

#Create a sphere of radius 1.
radius = 1
f3 = ROOT.TF3("sphere", "x*x+y*y+z*z-%f" % radius**2, -radius, radius, -radius, radius, -radius, radius)
#f3.SetClippingBoxOn(0,0,0)

#Array of points for line
line_points = np.array([[1, 0.4, 0.4], [-1, 0.4, 0.4]])
#We have to transpose this matrix to get rows of x, y, z
#Although this creates the right ordering it causes a TypeError in TGraph2D.
#line_points = np.transpose(line_points)
#We do this instead.
line_points = np.dstack(line_points)[0]

line = ROOT.TGraph2D(2, line_points[0], line_points[1], line_points[2])
line.SetLineColor(ROOT.kBlack)

f3.Draw("FBBB")
line.Draw("LINE SAME")
ROOT.gPad.Update()
raw_input("Press Enter to exit...")