GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||
GeezerVison is showing www.runoob.com — Matplotlib 绘图线 | 菜鸟教程
Matplotlib 教程
Matplotlib 教程
Matplotlib 安装
Matplotlib Pyplot
Matplotlib 绘图标记
Matplotlib 绘图线
Matplotlib 轴标签和标题
Matplotlib 网格线
Matplotlib 绘制多图
Matplotlib 散点图
Matplotlib 柱形图
Matplotlib 饼图
Matplotlib 直方图
Matplotlib imshow()
Matplotlib imsave()
Matplotlib imread()
Matplotlib 中文显示
Seaborn 教程
Matplotlib 常用函数
Matplotlib 参考文档
Matplotlib 绘图线绘图过程如果我们自定义线的样式,包括线的类型、颜色和大小等。 线的类型线的类型可以使用 linestyle 参数来定义,简写为 ls。
实例
import matplotlib.pyplot as plt import numpy as np ypoints = np.array([6, 2, 13, 10]) 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() 显示结果如下:
线的颜色线的颜色可以使用 color 参数来定义,简写为 c。 颜色类型:
当然也可以自定义颜色类型,例如:SeaGreen、#8FBC8F 等,完整样式可以参考 HTML 颜色值。 实例
import matplotlib.pyplot as plt import numpy as np ypoints = np.array([6, 2, 13, 10]) plt.plot(ypoints, color = 'r') plt.show() 显示结果如下:
实例
import matplotlib.pyplot as plt import numpy as np ypoints = np.array([6, 2, 13, 10]) plt.plot(ypoints, c = '#8FBC8F') plt.show() 显示结果如下:
实例
import matplotlib.pyplot as plt import numpy as np ypoints = np.array([6, 2, 13, 10]) plt.plot(ypoints, c = 'SeaGreen') plt.show() 显示结果如下:
线的宽度线的宽度可以使用 linewidth 参数来定义,简写为 lw,值可以是浮点数,如:1、2.0、5.67 等。 实例
import matplotlib.pyplot as plt import numpy as np ypoints = np.array([6, 2, 13, 10]) plt.plot(ypoints, linewidth = '12.5') plt.show() 显示结果如下:
多条线plot() 方法中可以包含多对 x,y 值来绘制多条线。 实例
import matplotlib.pyplot as plt import numpy as np y1 = np.array([3, 7, 5, 9]) y2 = np.array([6, 2, 13, 10]) plt.plot(y1) plt.plot(y2) plt.show() 从上图可以看出 x 的值默认设置为 [0, 1, 2, 3]。 显示结果如下: 我们也可以自己设置 x 坐标等值:
实例
import matplotlib.pyplot as plt import numpy as np x1 = np.array([0, 1, 2, 3]) y1 = np.array([3, 7, 5, 9]) x2 = np.array([0, 1, 2, 3]) y2 = np.array([6, 2, 13, 10]) plt.plot(x1, y1, x2, y2) plt.show() 显示结果如下:
AI 思考中...
点我分享笔记取消
分类导航
Advertisement
| |||||||||||||||||||||||||||||||||||||
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. | |||||||||||||||||||||||||||||||||||||