码迷,mamicode.com
首页 > 其他好文 > 详细

绘图和可视化

时间:2016-08-26 09:05:50      阅读:257      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

画图的步骤示例参考:
  1. import matplotlib.pyplot as plt
  2. %matplotlib inline
  3. from numpy.random import randn
  4. import numpy as np
  5. # 一种方法
  6. fig = plt.figure()
  7. ax1 = fig.add_subplot(2, 2, 1)
  8. ax2 = fig.add_subplot(2, 2, 2)
  9. ax3 = fig.add_subplot(2, 2, 3)
  10. ax4 = fig.add_subplot(2, 2, 4)
  11. plt.plot([1.5,3.5,-2,1.6]) # 在最后一个用过的subplot(如果没有则创建一个)上进行绘制
  12. ax1.hist(randn(100), bins=20, color=‘k‘, alpha=0.3)
  13. ax2.plot(randn(50).cumsum(), ‘k--‘)
  14. ax3.scatter(np.arange(30), np.arange(30) + 3 * randn(30))
  15. fig
  16. # 更简便的添加subplot的方法
  17. fig, axes = plt.subplots(2, 2, sharex=True, sharey=True)
  18. for i in range(2):
  19. for j in range(2):
  20. axes[i, j].hist(randn(500), bins=50, color=‘k‘, alpha=0.5)

技术分享

pandas中的绘图函数:
技术分享
技术分享
技术分享





绘图和可视化

标签:

原文地址:http://www.cnblogs.com/woaielf/p/5808980.html

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