def plot(data,ur,index,u_idx_pos,u_idx_neg): fig = plt.figure(figsize=(18, 6)) #Plot the second smallest eigen vetor u2 plt.subplot(131) x = u_idx_neg[0] y = ur[:,index[1]][u_idx_neg[0]] plt.ylim(-0.01,0.01) plt.scatter(x, y, color='b') x = u_idx_pos[0] y = ur[:,index[1]][u_idx_pos[0]] plt.ylim(-0.01,0.01) plt.scatter(x, y, color='r') #Plot the stubburn outlier x = np.arange(65,66,1) y = ur[:,index[1]][65] plt.scatter(x,y, color='g') #Plot the horizaontal line y=0, which we use to cluster plt.axhline(y=.0, xmin=-20, xmax=120, linewidth=1, color = 'k') #Plot the second smallest eigen vetor u2 plt.subplot(132) x = u_idx_neg[0] y = ur[:,index[1]][u_idx_neg[0]] plt.scatter(x, y, color='b') x = u_idx_pos[0] y = ur[:,index[1]][u_idx_pos[0]] plt.scatter(x, y, color='r') #Plot the stubburn outlier x = np.arange(65,66,1) y = ur[:,index[1]][65] plt.scatter(x,y, color='g') #Plot the horizaontal line y=0, which we use to cluster plt.axhline(y=.0, xmin=-20, xmax=120, linewidth=1, color = 'k') #Plot the cluster result axs2 = fig.add_subplot(133) plt_rex.plot2d(data[:,u_idx_neg[0]], colwise_data=True, hatch='bo', show=False, axs=axs2, set_aspect_equal=False, plotlabel="Neg") plt_rex.plot2d(data[:,u_idx_pos[0]], colwise_data=True, hatch='ro', show=False, axs=axs2, set_aspect_equal=False, plotlabel="Pos")
def PlotBaseAndScatter(x,y,axsList): X = np.vstack((x, y)) # only the measurements; data is col-wise xmin, ymin = X.min(axis=1) xmax, ymax = X.max(axis=1) xlim = [xmin, xmax] # purely for looks ylim = [ymin, ymax] plt_rex.plot2d(X, colwise_data=True, hatch='ro', x_lim=xlim, y_lim=ylim, show=False, axs=axsList[0], set_aspect_equal=False, title="Alternative and Median") plt_rex.plot2d(X, colwise_data=True, hatch='ro', x_lim=xlim, y_lim=ylim, show=False, axs=axsList[1], set_aspect_equal=False, title="Alternative and MidPoint") plt_rex.plot2d(X, colwise_data=True, hatch='ro', x_lim=xlim, y_lim=ylim, show=False, axs=axsList[2], set_aspect_equal=False, title="Alternative and SlidingMidPoint") plt_rex.plot2d(X, colwise_data=True, hatch='ro', x_lim=xlim, y_lim=ylim, show=False, axs=axsList[3], set_aspect_equal=False, title="High Variance and Median") plt_rex.plot2d(X, colwise_data=True, hatch='ro', x_lim=xlim, y_lim=ylim, show=False, axs=axsList[4], set_aspect_equal=False, title="High Variance and MidPoint") plt_rex.plot2d(X, colwise_data=True, hatch='ro', x_lim=xlim, y_lim=ylim, show=False, axs=axsList[5], set_aspect_equal=False, title="High Variance and SlidingMidPoint") return