importmatplotlib.pyplotasplt# 创建数据x=[1,2,3,4,5]y1=[1,4,9,16,25]y2=[1,8,27,64,125]y3=[1,16,81,256,625]# 绘制多条线plt.plot(x,y1,label='y = x^2')plt.plot(x,y2,label='y = x^3')plt.plot(x,y3,label='y = x^4')plt.title('Default Colors in Matplotlib - h...
matplotlib 2.0 版本之后,默认颜色不再是之前的 ['b', 'g', 'r', 'c', 'm', 'y', 'k',...], 所以使用 'b' 反而是奇怪的颜色,并不能调出默认颜色 '#1f77b4'。 为了与当前配色一致,可以使用colors = ['C0', 'C1', 'C2', ...], 或者可分别用 'C0' 到 'C9' 来调用这些颜色:color='...
dpi (default: 100.0): 代表每一英寸的打印点个数,即 分辨率。 The resolution of the figure in dots-per-inch. 字体大小 fontsize 是和 point 对应。参见If float, the fontsize in points. 线条粗细也是与 point 对应。参见Set the line width in points. 1 point = 0.3527 毫米 = 1/72 英寸,12号...
颜色(Colors): 基础颜色: 此外,matplotlib也支持HTML颜色,可参考:http://www.runoob.com/html/html-colorvalues.html。 (注:可直接上网搜索 ”HTML color names“) 也可用命令将其调出: importmatplotlibforname, hexinmatplotlib.colors.cnames.items():print(name, hex) aliceblue#F0F8FFantiquewhite#FAEBD7aqua#...
['red'ifx>np.mean(values)else'blue'forxinvalues]plt.bar(categories,values,color=colors)plt.title('Bar Chart with Threshold Colors - how2matplotlib.com')plt.xlabel('Categories')plt.ylabel('Values')plt.axhline(y=np.mean(values),color='green',linestyle='--',label='Mean')plt.legend()plt...
It's a shortcut string notation described in the *Notes* section below. >>> plot(x, y) # plot x and y using default line style and color >>> plot(x, y, 'bo') # plot x and y using blue circle markers >>> plot(y) # plot y using x as index array 0..N-1 >>> plot(...
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,),这个是...
``'-.'`` dash-dot line style ``':'`` dotted line style ``'.'`` point marker ``','`` pixel marker ``'o'`` circle marker ``'v'`` triangle_down marker ``'^'`` triangle_up marker ``'<'`` triangle_left marker ``'>'`` triangle_right marker ...
如果颜色是格式字符串的唯一部分,您还可以使用任何matplotlib.colors规范,例如全名 ( 'green') 或十六进制字符串 ( '#008000')。 五、示例格式字符串: 'b' # blue markers with default shape 'or' # red circles '-g' # green solid line '--' # dashed line with default color ...
line = Line2D(x, y) ax.add_line(line) ax.set_xlim(min(x), max(x)) ax.set_ylim(min(y), max(y)) plt.show() 1.2 设置 Line2D 属性的方式 方法1: 直接在plot()函数中设置 import matplotlib.pyplot as plt x = range(0,5)