1, a two-dimensional scatter plot
Two-dimensional scatter plot function prototype:
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, hold=None, data=None, **kwargs)
x
,y
Corresponding to the plane position of the point,s
Control point size,c
Corresponding color indication value, i.e. if the gradient, we set thec=x
can so that the color point according to the point ofx
change value,cmap
The type of adjustment or color gradient listmarker
Shape control pointsalpha
Transparency control point, I like to set up large volumes of data in a small timealpha
value, and then adjust thes
value so that an overlap effect makes data aggregation features will show up nicely: look at the results
The first setting opaque
fig = plt.figure() x = np.random.randn(10000) y = np.random.randn(10000) plt.scatter(x, y, c='b') plt.scatter(x+4, y, c='r')
The second set transparent
fig = plt.figure() x = np.random.randn(10000) y = np.random.randn(10000) plt.scatter(x, y, c='b', alpha=0.05) plt.scatter(x+4, y, c='r', alpha=0.05)
Then adjust the size of the spot
fig = plt.figure() x = np.random.randn(10000) y = np.random.randn(10000) plt.scatter(x, y, c='b', alpha=0.05, s=10) plt.scatter(x+4, y, c='r', alpha=0.05, s=10)
2, three-dimensional scatter plot
Three-dimensional scatter plot function prototype:
p3d.Axes3D.scatter( xs, ys, zs=0, zdir=’z’, s=20, c=None, depthshade=True, *args, **kwargs ) p3d.Axes3D.scatter3D( xs, ys, zs=0, zdir=’z’, s=20, c=None, depthshade=True, *args, **kwargs)
There are two versions of the three-dimensional scatter plot in p3d.Axes3D in, but the effect is the same:
xs
,ys
Representative pointx
,y
axis coordinateszs
Representativez
axis coordinate, but the two forms, the first is to take a scalar function prototype in default is a scalar0
, that is, by default all points are drawn on az=0
horizontal plane; the second is to take andxs
,ys
similarshape
to array, thereby specifying the actual z-axis coordinate of each point, as follows:
zs The default is 0;
fig = plt.figure() ax = Axes3D(fig) x = np.random.randn(10000) y = np.random.randn(10000) ax.scatter(x, y, c='b', s=10, alpha=0.05) ax.scatter(x+4, y, c='r', s=10, alpha=0.05)
Take a scalar zs
fig = plt.figure() ax = Axes3D(fig) x = np.random.randn(10000) y = np.random.randn(10000) ax.scatter(x, y, c='b', s=10, alpha=0.05) ax.scatter(x+4, y, 2, c='r', s=10, alpha=0.05)
zs take an array
fig = plt.figure() ax = Axes3D(fig) z = 6*np.random.randn(5000) x = np.sin(z) y = np.cos(z) ax.scatter(x, y, z, c='r', s=10, alpha=0.05)
Reference: https: //www.jianshu.com/p/9390b49ad993