Scatter Plots
The graph consists of two axes, each representing a set of data.
Scatter plots’ primary uses are to observe and show relationships between two numeric variables. The dots in a scatter plot not only report the values of individual data points but also patterns when the data are taken as a whole.
The identification of correlational relationships is common with scatter plots.
A scatter plot can also be useful for identifying other patterns in data.
In order to create a scatter plot, we need to select two columns from a data table, one for each dimension of the plot. Each row of the table will become a single dot in the plot with the position according to the column values.
x, y: array_like, shape (n, )
s: the size of the dots ... we can make it with different sizes.
c: color
marker: the shape of the dots.
edgecolor : the edge color of the dot
linewidth: the width of the edge line of the dot.
alpha: the contrast od the dot color from 0 to 1
c=colors, cmap='Greens' : to make the dot colors according to a color map.
Example:
x = [1, 2, 3, 4, 15, 6, 7, 8, 9, 10]
y = [5, 6, 8, 9, 4, 7, 6, 3, 5, 12]
colors = [j for j in x]
sizes = [i * 20 for i in y]
Scatter plots’ primary uses are to observe and show relationships between two numeric variables. The dots in a scatter plot not only report the values of individual data points but also patterns when the data are taken as a whole.
The identification of correlational relationships is common with scatter plots.
A scatter plot can also be useful for identifying other patterns in data.
In order to create a scatter plot, we need to select two columns from a data table, one for each dimension of the plot. Each row of the table will become a single dot in the plot with the position according to the column values.
matplotlib.pyplot
.
scatter
(x, y, s=None, c=None, marker=None, cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None, *, plotnonfinite=False, data=None, **kwargs)
A scatter plot of y vs x with varying marker size and/or color.
Parameters:
The data positions.
s: the size of the dots ... we can make it with different sizes.
c: color
marker: the shape of the dots.
edgecolor : the edge color of the dot
linewidth: the width of the edge line of the dot.
alpha: the contrast od the dot color from 0 to 1
x = [1, 2, 3, 4, 15, 6, 7, 8, 9, 10]
y = [5, 6, 8, 9, 4, 7, 6, 3, 5, 12]
colors = [j for j in x]
sizes = [i * 20 for i in y]
plt.scatter(x, y, s=sizes, c=colors, cmap='Greens', edgecolor='black', linewidth=1, alpha=0.75)
cbar = plt.colorbar()
cbar.set_label('satisfiction')
plt.xlabel('x values')
plt.ylabel('y values')
cbar = plt.colorbar()
cbar.set_label('satisfiction')
plt.xlabel('x values')
plt.ylabel('y values')
plt.title('plot title')
print(plt.style.available)
plt.style.use('seaborn-darkgrid')
Comments
Post a Comment