2018-12-17
2018-12-17 本文已影响0人
wangj676
matplotlib 记录
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4], [1, 4, 9, 16],'o')
plt.axis([0, 6, 0, 20]) // The axis() command in the example above takes a list of [xmin, xmax, ymin, ymax] and specifies the viewport of the axes.
'''
red dashes, blue squares and green triangles : //different types of dots
'r--','bs','g^'
'''
plt.show()
list来进行绘图
name=['group_a','group_b','group_c']
values=[1,10,100]
plt.figure(1,figsize=(9,3))
'''
num : integer or string, optional, default: None
If not provided, a new figure will be created, and the figure number
will be incremented. The figure objects holds this number in a `number`
attribute.
If num is provided, and a figure with this id already exists, make
it active, and returns a reference to it. If this figure does not
exists, create it and returns it.
If num is a string, the window title will be set to this figure's
`num`.
figsize : tuple of integers, optional, default: None
width, height in inches. If not provided, defaults to
:rc:`figure.figsize` = ``[6.4, 4.8]``.
'''
plt.subplot(131) #第一行有三个子图,现画第一个图 柱形图
plt.bar(name,values)
plt.subplot(132) #第一行有三个子图,现画第二个图 点状图
plt.scatter(name,values)
plt.subplot(133) #第一行有三个子图,现画第三个图 折线图
plt.plot(name,values)
plt.show() #显示图像
注:python注释 可以用''' content '''或者 #
总结:
主要是figure画布的生成,之后可以利用subplot进行子画布的工作,可以通过一些参数的设置对图像进行更高程度的修饰,最后show()方法显示出来即可。