annayqho / TheCannon

a data-driven method for determining stellar parameters and abundances from stellar spectra
MIT License
39 stars 16 forks source link

Masked numpy array for plotting #46

Closed tingyuansen closed 8 years ago

tingyuansen commented 9 years ago

In some occasions, the code plots the results using masked numpy arrays. This might mess up the plotting. For example, if one considers np.ma.array(A, mask=[0,1,0,0,0]), only the last three entries are plotted, even though the first entry is not masked.

annayqho commented 9 years ago

sorry, I don't understand. why wouldn't the first entry in this case be plotted?

tingyuansen commented 9 years ago

Hi Anna,

Sorry for not being clearer, what I meant is that there will be a broken part in the plot. You can try the following codes to see the difference.

x_array = np.arange(6) y_array = np.arange(6) y_array_masked = np.ma.array(y_array, mask=[0,0,1,0,0,0]) plt.plot(x_array,y_array_masked)

x_array_restricted = x_array[np.where(x_array != 2)] y_array_restricted = y_array[np.where(x_array != 2)] plt.plot(x_array_restrict,y_array_restrict)

Thanks!