Every line of 'scatter plot matplotlib' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
26 def scatterplot(x_data, y_data, x_label, y_label, title): 27 """ 28 Arguments: 29 x_data: Series. Desired x-axis for scatterplot. 30 y_data: Series. Desired y-axis for scatterplot. 31 x_label: String. Label for x-axis. 32 y_label: String. Label for y-axis. 33 title: String. Title of plot 34 Outputs: 35 Scatterplot in console. 36 """ 37 fig, ax = plt.subplots() 38 ax.scatter(x_data, y_data, s = 30, color = '#539caf', alpha = 0.75) 39 ax.set_title(title) 40 ax.set_xlabel(x_label) 41 ax.set_ylabel(y_label) 42 fig.autofmt_xdate()
18 def scatter(x, y, plot_name): 19 """ Used to plot t-SNE projections """ 20 21 num_colors = len(np.unique(y)) 22 # We choose a color palette with seaborn. 23 palette = np.array(sns.color_palette("hls", num_colors)) 24 # We create a scatter plot. 25 f = plt.figure(figsize=(8, 8)) 26 ax = plt.subplot(aspect='equal') 27 sc = ax.scatter(x[:,0], x[:,1], lw=0, s=40, 28 c=palette[y.astype(np.int)]) 29 plt.xlim(-25, 25) 30 plt.ylim(-25, 25) 31 ax.axis('off') 32 ax.axis('tight') 33 # We add the labels for each digit. 34 txts = [] 35 for i in range(num_colors): 36 # Position of each label. 37 xtext, ytext = np.median(x[y == i, :], axis=0) 38 # if np.isnan(xtext) or np.isnan(ytext): 39 # break 40 txt = ax.text(xtext, ytext, str(i), fontsize=24) 41 txt.set_path_effects([ 42 PathEffects.Stroke(linewidth=5, foreground="w"), 43 PathEffects.Normal()]) 44 txts.append(txt) 45 46 plt.savefig(plot_name, dpi=120) 47 plt.close()
99 def make_chart_scatter_plot(plt): 100 101 friends = [ 70, 65, 72, 63, 71, 64, 60, 64, 67] 102 minutes = [175, 170, 205, 120, 220, 130, 105, 145, 190] 103 labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'] 104 105 plt.scatter(friends, minutes) 106 107 # label each point 108 for label, friend_count, minute_count in zip(labels, friends, minutes): 109 plt.annotate(label, 110 xy=(friend_count, minute_count), # put the label with its point 111 xytext=(5, -5), # but slightly offset 112 textcoords='offset points') 113 114 plt.title("Daily Minutes vs. Number of Friends") 115 plt.xlabel("# of friends") 116 plt.ylabel("daily minutes spent on the site") 117 plt.show()
60 def scatterplot(x, y, z=None, **kwargs): 61 """ 62 Create a 2D scatterplot. Parameter `z` is for a unified API. 63 64 Args: 65 x (iterable): Values for x-axis. 66 y (iterable): Values for y-axis. 67 **params: Any other keyword argument passed to `go.Scatter`. 68 69 Returns: 70 `go.Scatter` 71 """ 72 73 return _simple_scatter(x, y, mode="markers", **kwargs)
57 def plot(X, y, title, min_label, maj_label, filename): 58 plt.figure(figsize= (4, 3)) 59 plt.scatter(X[:,0][y == min_label], X[:,1][y == min_label], label='minority class', color='red', s=25) 60 plt.scatter(X[:,0][y == maj_label], X[:,1][y == maj_label], label='majority class', color='black', marker='*', s=25) 61 plt.xlabel('feature 0') 62 plt.ylabel('feature 1') 63 plt.title(title) 64 plt.legend() 65 plt.tight_layout() 66 plt.savefig(filename) 67 plt.show()
85 def _create_scatter_plot(actual, predicted): 86 import matplotlib.pyplot as plt 87 88 fig = plt.figure() 89 ax = fig.add_subplot(1, 1, 1) 90 ax.set_title("Actual vs. Predicted") 91 ax.set_xlabel("Actual Labels") 92 ax.set_ylabel("Predicted Values") 93 ax.scatter(actual, predicted) 94 return fig
672 def test_scatter_custom_ticklabels(self): 673 ax = scprep.plot.scatter2d(self.X_pca, xticks=[0, 1, 2], 674 xticklabels=['a', 'b', 'c']) 675 assert np.all(ax.get_xticks() == np.array([0, 1, 2])) 676 xticklabels = np.array([lab.get_text() 677 for lab in ax.get_xticklabels()]) 678 assert np.all(xticklabels == np.array(['a', 'b', 'c']))
776 def test_scatter_colorbar(self): 777 scprep.plot.scatter3d(self.X_pca, c=self.X_pca[:, 0], colorbar=True)
96 def _scatter_renderer_default(self): 97 renderer = _create_scatter_renderer(self.plot) 98 return renderer
28 def plotScatter(X0, X1, y): 29 for x0, x1, cls in zip(X0, X1, y): 30 colors = ['blue', 'black', 'red'] 31 markers = ['x', 'o', '*'] 32 color = colors[int(cls)-1] 33 marker = markers[int(cls)-1] 34 plt.scatter(x0, x1, marker=marker, color=color)