首页 > 代码库 > Python-绘图
Python-绘图
import pylab (or matplotlib.pyplot) as pl
创建图表
pl.figure(1) # 创建图表一
pl.figure(2) # 创建图表二
······
sub_fig_211 = pl.subplot(211) # 在图表中创建子图
sub_fig_212 = pl.subplot(212) # 在图表中创建子图, 图2子图:第1列第2行
通过pl.figure(1) pl.sca(sub_fig_212) 来选取图表和子图
绘图
pl.plot(x1, y1, ‘r‘) pl.plot(x2, y2, ‘b‘)
pl.xlim(0, 100) # x轴范围
pl.ylim(0, 100) # y轴范围
标题&坐标轴
pl.tilte("figure title") # 标题
pl.xlabel("x axis label") # x 轴标注
pl.ylabel("y axis label") # y 轴标注
颜色
pl.plot(x2, y2, ‘b‘)
值 | 颜色 |
b | blue 蓝色 |
c | cyan 蓝绿色 |
g | green 绿色 |
k | black 黑色 |
m | magenta 品红色 |
r | red 红色 |
y | yellow 黄色 |
w | white 白色 |
线条样式
pl.plot(x2, y2, ‘b--‘)
值 | "-" | "--" | "-." | ":" | "None" | " " | "" |
线型 | solid 实线 | dashed 虚线 | dash_dot 虚线+点 | dotted 点 | nothing | nothing | nothing |
Show
pl.sca(sub_fig_212)
pl.plot(x2, y2, ‘g--‘)
pl.show()
Python-绘图
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。