先说明一下,总看到NLP群里有人问跟画图作斗争,我觉得完全没必要。自然语言处理里对于画图没什么要求,原因是文本的特征一般都是高维的,即使降维,图像对于显示数据内在的本质没有什么太大帮助,因此即使不会绘图也没什么关系。市面上有几本讲matplotlib的书籍,也基本上都是国外的,讲的内容也没有什么特别实际的用途。下边小结一下scatter散点图的绘制方法。
说明文档地址
matplotlib.pyplot.scatter - Matplotlib 3.1.0 documentationmatplotlib.org原型
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,*,data=None,**kwargs)
参数
- x,y: 类数组,形状为n行
- s:标量或类数组,形状为n行
- c:clolor类型,序列,color序列。颜色的标记
- 1个color格式的字符串
- color说明的长度为n的序列
- 映射为色彩的数值序列
- 2维数组,数组的每行表示1个RGB色彩
- marker:MarkerStyle类型。绘图标记的风格。参数值可以是MarkerStyle类实例也可以是一种特定标记风格的简写文本
返回
- paths:PathCollection用于传给legend的参数
颜色参数可取字符串值列表
标记类型可取值字符串列表
'.': 'point',
',': 'pixel',
'o': 'circle',
'v': 'triangle_down',
'^': 'triangle_up',
'<': 'triangle_left',
'>': 'triangle_right',
'1': 'tri_down',
'2': 'tri_up',
'3': 'tri_left',
'4': 'tri_right',
'8': 'octagon',
's': 'square',
'p': 'pentagon',
'*': 'star',
'h': 'hexagon1',
'H': 'hexagon2',
'+': 'plus',
'x': 'x',
'D': 'diamond',
'd': 'thin_diamond',
'|': 'vline',
'_': 'hline',
'P': 'plus_filled',
'X': 'x_filled',
0: 'tickleft',
1: 'tickright',
2: 'tickup',
3: 'tickdown',
4: 'caretleft',
5: 'caretright',
6: 'caretup',
7: 'caretdown',
8: 'caretleftbase',
9: 'caretrightbase',
10: 'caretupbase',
11: 'caretdownbase',
'None': 'nothing',
None: 'nothing',
' ': 'nothing',
'': 'nothing'