x=np.linspace(0,10,100)y=np.sin(x)plt.figure(figsize=(8,6))plt.plot(x,y,linestyle='dotted',linewidth=2,color='blue',label='how2matplotlib.com')plt.title('Dotted Line Example')plt.xlabel('X-axis')plt.ylabel('Y-axis')plt.legend()plt.grid(True)plt.show() Python Copy Output: ...
plt.plot(ypoints, linestyle = 'dotted') plt.show()显示结果如下:使用简写:实例 import matplotlib.pyplot as plt import numpy as np ypoints = np.array([6, 2, 13, 10]) plt.plot(ypoints, ls = '-.') plt.show()显示结果如下:线
一般来说:实线('solid')('-');点线('dotted')(':');虚线('dashed')('--');点划线('dashdot')('-.')最为常用。 进阶设置排列、不同样式可以参考官方文档 我们把线调整为点划线,粗细为2,如下图: plt.figure(dpi=300)foriinrange(0,10):y.append(x**2+1*i)plt.plot(x,y[i],c=color_l...
plt.plot(x, y, linestyle='--', label='Dashed Line') ``` 虚线常用于表示辅助线或参考线,用来强调某些重要的数据点或趋势。 三、点线(Dotted Line) 点线是由一系列短点组成的线条,它们之间没有连接线段。在matplotlib中,我们可以使用':'作为linestyle参数的取值来绘制点线,例如: ``` plt.plot(x, y...
plt.plot(ypoints,linestyle='dotted') plt.show() 显示结果如下: 使用简写: 实例 importmatplotlib.pyplot as pltimportnumpy as np ypoints= np.array([6, 2, 13, 10]) plt.plot(ypoints,ls='-.') plt.show() 显示结果如下: 线的颜色
'-':实线(solid line style) '--':虚线(dashed line style) '-.':点划线(dash-dot line style) ':':点线(dotted line style) 绘制散点图 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...
1. '-' solid line style 2. ‘--’ dashed line style 3. '-.' dash-dot line style 4. ':' dotted line style 三、数据点形状 1. '.' point marker 2. 'o' circle marker 3. 'v' triangle_down marker 4. '^' triangle_down marker ...
plot方法的关键字参数linestyle(或ls)用来设置线的样式。 如plt.plot(x, y1, linestyle=':') 或 plt.plot(x, y1, ls=':') 可取值为: - 实线(solid) -- 短线(dashed) -. 短点相间线(dashdot) : 虚点线(dotted) '', ' ', None 4.线条大小 ...
plt.plot([4.5,2,3],marker='o') [<matplotlib.lines.Line2D at 0x7f6f0350d438>] 2个参数 自动解析位置参数的原则 (x,y)形式 # x/y 为序列plt.plot([2,1,3],[0.5,2,2.5],marker='o') [<matplotlib.lines.Line2D at 0x7f6f034735c0...
('dashdotdotted', (0, (3, 5, 1, 5, 1, 5))), ('loosely dashdotdotted', (0, (3, 10, 1, 10, 1, 10))), ('densely dashdotdotted', (0, (3, 1, 1, 1, 1, 1)))]defplot_linestyles(ax, linestyles): X, Y= np.linspace(0, 100, 10), np.zeros(10) ...