码迷,mamicode.com
首页 > 编程语言 > 详细

Python画图

时间:2016-12-02 18:54:32      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:技术   com   size   blog   style   splay   closed   pre   indicator   

plt 离散点图 subplot:

‘-‘就会拟合

技术分享
 1 import matplotlib.pyplot as plt
 2 
 3 plt.plot(data[‘TV‘], y, ‘ro‘, label=‘TV‘)
 4     plt.plot(data[‘Radio‘], y, ‘g^‘, label=‘Radio‘)
 5     plt.plot(data[‘Newspaper‘], y, ‘mv‘, label=‘Newspaer‘)
 6     plt.legend(loc=‘lower right‘)
 7     plt.grid()
 8     plt.show()
 9 
10 
11 plt.figure(figsize=(9,12)) #设置图的大小 宽9inch 高12inch
12     plt.subplot(311)
13     plt.plot(data[‘TV‘], y, ‘ro‘)
14     plt.title(‘TV‘)
15     plt.grid()
16     plt.subplot(312)
17     plt.plot(data[‘Radio‘], y, ‘g^‘)
18     plt.title(‘Radio‘)
19     plt.grid()
20     plt.subplot(313)
21     plt.plot(data[‘Newspaper‘], y, ‘b*‘)
22     plt.title(‘Newspaper‘)
23     plt.grid()
24     plt.tight_layout() # 紧凑显示图片,居中显示
25     plt.show()
View Code

 

Python画图

标签:技术   com   size   blog   style   splay   closed   pre   indicator   

原文地址:http://www.cnblogs.com/futurehau/p/6126696.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!