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 c g k m r y w
颜色 blue 蓝色 cyan 蓝绿色 green 绿色 black 黑色 magenta 品红色 red 红色 yellow 黄色 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()

 

posted on 2017-06-27 12:51  冰冻五尺  阅读(236)  评论(0)    收藏  举报

导航