I would like to perform plots/fits for x-y data, provided that the data set's x values meet a condition (i.e. are greater than 10).

My attempt:

x_values, y_values = loadtxt(fname, unpack=True, usecols=[1, 0])

for x in x_values:
    if x > 10:
        (m,b)=polyfit(x_values,y_values,1)
        yp = polyval([m,b],x_values)
        plot(x_values,yp)
        scatter(x_values,y_values)
    else:
        pass

Perhaps it would be better to remove x-y entries for rows where the x value condition is not met, and then plot/fit?

Edit
Report