Hi, since your y values are all of order 1E-16 or so, matplotlib adjusted the y-axis accordingly and on that scale the curve is not smooth because e.g. points with y equal to 1E-16 and 9E-16 (which is 0) take you from one end of axis to another. So the fix is
plt.ylim([-1, 1])
Btw, why is it necessary represent the surface as vector map: x, y --> x, y, z? You know what x, y are so a scalar map: x, y --> z seems to be a more appropriate choice. The code would then look as follows (note that it does not need ylim adjustment)
from dolfin import *
import numpy as np
mesh = CircleMesh(Point(0.0,0.0), 1.0, 0.1)
space = FunctionSpace(mesh, "CG", 2)
X = Function(space)
X.interpolate(Expression("x[0]*x[0]+x[1]*x[1]"))
plot(X, interactive=True)
x_coords = np.linspace(-0.9, 0.9, 10)
y_coords = np.zeros(len(x_coords))
z_coords = np.zeros(len(x_coords))
for i, (x, y) in enumerate(zip(x_coords, y_coords)):
z_coords[i] = X(x, y)
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot(x_coords, y_coords, z_coords)
plt.show()