5 examples of 'scatter plot python' in Python

Every line of 'scatter plot python' 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.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
26def 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()
60def 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)
18def 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()
96def _scatter_renderer_default(self):
97 renderer = _create_scatter_renderer(self.plot)
98 return renderer
99def 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()

Related snippets