Although the accepted answer is good if all you want to do is turn off the axes lines, I would suggest getting familiar with the .set()
function as you can pass additional kwargs controlling the line style, thickness, etc etc, making your code more flexible and re-usable. It also cuts down on the number of matplotlib functions you need to learn.
Op can do this:
ax.spines.top.set(visible=False)
ax.spines.right.set(visible=False)
but you can just as easily do something like this:
ax.spines.right.set(color='red', linestyle='--', linewidth=2, position=['data',2])
ax.spines.top.set(color='red', linestyle='--', linewidth=2, position=['data',5])

See documentation here.