based on Rutger Kassies ides:
n_points = 100
x=np.setdiff1d(np.linspace(-10,10,n_points),[0]) #to remove the zero
y=f(x)
y[n_points//2-1:n_points//2+1] = np.nan
use your original plot an set the points around 0 to np.nan. that way too many points get set to None but it's symmetric.
you could also setup your linspace to includ 0 such that f(x) = np.nan: n_points = 101. (this answer and 2 comments stated that right before i did... please credit there).