array-like or list of colors or color, optionalThe marker colors. Possible values:- A scalar or sequence of n numbers to be mapped to colors using*cmap* and *norm*.- A 2-D array in which the rows are RGB or RGBA.- A sequence of colors of length n.- A single color format string.
marker:表示的是标记的样式,默认的是’o’。
`~.markers.MarkerStyle`, default: :rc:`scatter.marker`The marker style. *marker* can be either an instance of the class or the text shorthand for a particular marker.See :mod:`matplotlib.markers` for more information about marker styles.
str or `~matplotlib.colors.Colormap`, default::rc:`image.cmap`A `.Colormap` instance or registered colormap name. *cmap* is only used if *c* is an array of floats.
`~matplotlib.colors.Normalize`, default: NoneIf *c* is an array of floats, *norm* is used to scale the color data, *c*, in the range 0 to 1, in order to map into the colormap *cmap*.If *None*, use the default `.colors.Normalize`.
vmin,vmax:实数,用来进行亮度数据的归一化。vmin 和 vmax 与默认范数结合使用,将颜色数组 c 映射到颜色图 cmap。 如果没有,则使用颜色数组的相应最小值和最大值。 当norm存在的时候忽略。
float, default: None*vmin* and *vmax* are used in conjunction with the default norm tomap the color array *c* to the colormap *cmap*. If None, therespective min and max of the color array is used.It is deprecated to use *vmin*/*vmax* when *norm* is given.
alpha:实数,0-1之间。表示线的透明度
float, default: NoneThe alpha blending value, between 0 (transparent) and 1 (opaque).
linewidths:也就是标记点的宽度。
float or array-like, default: :rc:`lines.linewidth`The linewidth of the marker edges. Note: The default *edgecolors*is 'face'. You may want to change this as well.
散点的形状
颜色参数
用法示例
1、初始用法
import numpy as np import matplotlib.pyplot as pltnp.random.seed(2021)#随机数种子 x=np.random.rand(10)#生成指定形状的随机数组,值分布在[0,1) y=np.random.rand(10)#也可以设置产生的形状,例如将10换成(3,2)colors=np.random.rand(10) area=(30*np.random.rand(10))**2#这里设置s的大小#如果s固定,那么大小一致 plt.scatter(x,y,s=area,c=colors,alpha=0.5) plt.show()
运行结果:
2、修改代码的maker,改成钻石形状
import numpy as np import matplotlib.pyplot as pltnp.random.seed(2021) x=np.random.rand(10) y=np.random.rand(10)colors=np.random.rand(10) area=(30*np.random.rand(10))**2plt.scatter(x,y,s=area,c=colors,alpha=0.5,marker='D') plt.show()
3、设置s大小不变
import numpy as np import matplotlib.pyplot as pltnp.random.seed(2021) x=np.random.rand(10) y=np.random.rand(10)colors=np.random.rand(10)plt.scatter(x,y,s=300,c=colors,alpha=0.5,marker='D') plt.show()