How to use the matplotlib.pyplot.scatter function in matplotlib

To help you get started, we’ve selected a few matplotlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tuckerbalch / QSTK / trunk / qstktest / testLearner.py View on Github external
savefig("scatterdata3D.png", format='png')
plt.close()

#
# Compare to ground truth
#
print 'trainsize ' + str(trainsize)
Ytruth = Y[-trainsize:]
print 'Ytruth.shape ' + str(Ytruth.shape)
Xtest = dataX[-trainsize:,:]
print 'Xtest.shape ' + str(Xtest.shape)
Ytest = learner.query(Xtest) # to check every point
print 'Ytest.shape ' + str(Ytest.shape)

plt.clf()
plt.scatter(Ytruth,Ytest,edgecolors='none')
plt.xlim(-1.2,1.2)	# set x scale
plt.ylim(-1.2,1.2)	# set y scale
plt.xlabel('Ground Truth')
plt.ylabel('Estimated')
savefig("scatterdata.png", format='png')

print corrcoef(Ytruth,Ytest)
github scikit-learn / scikit-learn / examples / svm / plot_svm_kernels.py View on Github external
# figure number
fignum = 1

# fit the model
for kernel in ('linear', 'poly', 'rbf'):
    clf = svm.SVC(kernel=kernel, gamma=2)
    clf.fit(X, Y)

    # plot the line, the points, and the nearest vectors to the plane
    plt.figure(fignum, figsize=(4, 3))
    plt.clf()

    plt.scatter(clf.support_vectors_[:, 0], clf.support_vectors_[:, 1], s=80,
                facecolors='none', zorder=10, edgecolors='k')
    plt.scatter(X[:, 0], X[:, 1], c=Y, zorder=10, cmap=plt.cm.Paired,
                edgecolors='k')

    plt.axis('tight')
    x_min = -3
    x_max = 3
    y_min = -3
    y_max = 3

    XX, YY = np.mgrid[x_min:x_max:200j, y_min:y_max:200j]
    Z = clf.decision_function(np.c_[XX.ravel(), YY.ravel()])

    # Put the result into a color plot
    Z = Z.reshape(XX.shape)
    plt.figure(fignum, figsize=(4, 3))
    plt.pcolormesh(XX, YY, Z > 0, cmap=plt.cm.Paired)
    plt.contour(XX, YY, Z, colors=['k', 'k', 'k'], linestyles=['--', '-', '--'],
github Nikronic / Machine-Learning-Models / Part 2 - Regression / Section 7 - Random Forest Regression / rfr.py View on Github external
from sklearn.ensemble import RandomForestRegressor
regressor = RandomForestRegressor(n_estimators = 500, random_state = 0)
regressor= regressor.fit(x,y)
regressor2 = RandomForestRegressor(n_estimators = 10, random_state = 0) # trey to show diff in number of trees
regressor2 = regressor2.fit(x,y)


# making prediction
y_pred = regressor.predict(6.5)

# visualize the fitted model and our data
# we can see average values calculated by Random Forest Regression.
# Each step is one section with its information entropy.
x_grid = np.arange(min(x),max(x),0.01)
x_grid = x_grid.reshape(-1,1)
plt.scatter(x,y, color ='red', alpha=0.6)
plt.scatter(6.5,y_pred,color = 'blue', marker='D',alpha = 0.5)
plt.plot(x_grid,regressor.predict(x_grid),color='green' , alpha= 0.7)
plt.plot(x_grid,regressor2.predict(x_grid),color='purple', alpha = 0.6)
plt.title('Level vs Salary (train data) using Decision Tree Regression')
plt.xlabel('Level')
plt.ylabel('Salary')
plt.legend()
plt.grid()
plt.show()
github Jose-Alvarez / FMC / plotFMC.py View on Github external
Y,
            s=size,
            c=color,
            alpha=0.7,
            linewidth=1.5,
			edgecolors='black',
            cmap='plasma_r')
        cbar = plt.colorbar(sc, shrink=0.5)
        cbar.set_label(label)
    # legend
    plt.scatter(0.3, 0.9, s=16, c='white', linewidth=1.5, edgecolors='black')
    plt.scatter(0.4, 0.9, s=25, c='white', linewidth=1.5, edgecolors='black')
    plt.scatter(0.5, 0.9, s=36, c='white', linewidth=1.5, edgecolors='black')
    plt.scatter(0.6, 0.9, s=49, c='white', linewidth=1.5, edgecolors='black')
    plt.scatter(0.7, 0.9, s=64, c='white', linewidth=1.5, edgecolors='black')
    plt.scatter(0.8, 0.9, s=81, c='white', linewidth=1.5, edgecolors='black')
    plt.text(0.3, .95, '4', fontsize=10)
    plt.text(0.4, .95, '5', fontsize=10)
    plt.text(0.5, .95, '6', fontsize=10)
    plt.text(0.6, .95, '7', fontsize=10)
    plt.text(0.7, .95, '8', fontsize=10)
    plt.text(0.8, .95, '9', fontsize=10)
    plt.text(0.85, .95, 'Mw', fontsize=10)
    return fig
github eredmiles / Fraud-Corruption-Detection-Data-Science-Pipeline-DSSG2015 / WorldBank2015 / Code / modeling / model_pipeline_script.py View on Github external
plt.scatter(x=X[y==c, 0],
                    y=y_data,
                    alpha=0.8,
                    c=cmap(c),
                        marker=next(marker_gen),
                    label=c)

    if legend:
        plt.legend(loc=legend, fancybox=True, framealpha=0.5)

    print X
    if plot_testdata:
        if dim == '2d':
            plt.scatter(X[:,0], X[:,1], c='', alpha=1.0, linewidth=1, marker='o', s=80)
        else:
            plt.scatter(X, [0 for i in X], c='', alpha=1.0, linewidth=1, marker='o', s=80)
github flatironinstitute / CaImAn / use_cases / CaImAnpaper / scripts_paper / figure_9 / Figure_9_alignment.py View on Github external
plt.xlim((3, dims[0]-7))
plt.axis('off')
day = [mlines.Line2D([], [], color=cl[i], label='Day '+str(i+1)) for i in range(N)]
plt.legend(handles=day, loc=3)
dist_pair = [pair[1]-pair[0] for pair in pairs]
ax2 = plt.subplot2grid((3, 3), (0, 2))
plt.scatter(dist_pair,f1_forw,c='r')
plt.scatter(dist_pair,f1_back,c='b')
plt.title('F_1 score, union vs direct matching')
day = [mlines.Line2D([], [], color='r', label='Forward')] + [mlines.Line2D([], [], color='b', label='Backward')]
plt.legend(handles=day, loc=1)
plt.ylim((0.975,1.002))
plt.xlabel('Time difference between session (days)')

ax3 = plt.subplot2grid((3, 3), (1, 2))
plt.scatter(ln,f1_fb)
plt.title('F_1 score, forward vs backward')
plt.ylim((0.975, 1))
plt.xlabel('Number of sessions')
plt.tight_layout()
github fnbalves / zero_shot_learning / visualize_results.py View on Github external
def show_label_points(label):
    target_point = make_graph(label)
    wx = [x for i, x in enumerate(x_output) if points_labels[i] == label]
    wy = [y for i, y in enumerate(y_output) if points_labels[i] == label]
    plt.scatter(wx, wy, c='red')
    plt.scatter(target_point[0], target_point[1], c='green')
    plt.title(label)
    plt.savefig(os.path.join(FOLDER_TO_SAVE, label + '.png'), format='png', dpi=1000)
github boland1992 / SeisSuite / ambient / network_spacing / rand_box.py View on Github external
#   x = [[i] for i in x]
    
 #   y = np.random.rand(n)
 #   y = [[i] for i in y]
    
    #generate grid of random points within a 1x1 box    
    X = np.random.rand(n,2)

    k = kmeans(X, 20)
    print type(X)
    counts+=1



    #plt.scatter(X[:,0],X[:,1])
    plt.scatter(k[0][:,0], k[0][:,1], alpha = opac)
    plt.xlim(0,1.)
    plt.ylim(0,1.) 
    
    opac *= 0.9

plt.show()
github DSC-SPIDAL / harp / harp-daal-python / examples / scdemo / src / demo_kmeans.py View on Github external
print('===>predict by trained KMeans model on 2D dimension with %.2fs'%(time() - t1))

# Put the result into a color plot
t1 = time()
Z = Z.reshape(xx.shape)
plt.figure(1)
plt.clf()
plt.imshow(Z, interpolation='nearest',
           extent=(xx.min(), xx.max(), yy.min(), yy.max()),
           cmap=plt.cm.Paired,
           aspect='auto', origin='lower')

plt.plot(reduced_data[:, 0], reduced_data[:, 1], 'k.', markersize=2)
# Plot the centroids as a white X
centroids = kmeans.cluster_centers_
plt.scatter(centroids[:, 0], centroids[:, 1],
            marker='x', s=169, linewidths=3,
            color='w', zorder=10)
plt.title('K-means clustering on the image dataset (PCA-reduced data)\n'
          'Centroids are marked with white cross')
plt.xlim(x_min, x_max)
plt.ylim(y_min, y_max)
plt.xticks(())
plt.yticks(())
plt.savefig('kmeans_2d.png')
plt.show()

print('===>draw plot of clusters on 2D dimension with %.2fs, check result at kmeans_2d.png'%(time() - t1))
github ShangtongZhang / DeepRL / plot_paper.py View on Github external
'data/ASquaredC/dm-cheetah_episode_1998848_options.bin',
    ]

    for j, file in enumerate(files):
        plt.figure(figsize=(10, 0.2))
        plt.tight_layout()
        with open(file, 'rb') as f:
            options = pickle.load(f)
        options = np.asarray(options)
        xs = []
        for i in range(4):
            xs.append(np.argwhere(options == i).flatten())

        for i, x in enumerate(xs):
            y = np.ones(len(x))
            plt.scatter(x, y, color=colors[i], marker='|')

        plt.axis('off')
        plt.savefig('%s/options-%d.png' % (FOLDER, j), bbox_inches='tight')