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

stackplot

时间:2014-11-04 19:36:46      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   for   sp   div   on   2014   

# -*- coding: utf-8 -*-
"""
Created on Tue Nov 04 15:46:32 2014

@author: dell
"""

import numpy as np
import matplotlib.pyplot as plt

if __name__ == __main__:
    mylist = [np.random.uniform(30, 50, 100) for i in range(3)]
    #mylist = [np.random.randint(30, 50, 100) for i in range(3)]
    y = np.row_stack(mylist)
    
    x = range(0, 100)
    
    fig = plt.figure()
    ax1 = fig.add_subplot(311)
    ax1.stackplot(x, y)
    #plt.show()
    
    ax2 = fig.add_subplot(312)
    ax2.plot(x,mylist[0], -.)
    ax2.plot(x,sum(mylist[0:2]), --)
    ax2.plot(x,sum(mylist[0:3]), :)
    
    ax3 = fig.add_subplot(313)
    ax3.stackplot(x, y)
    y_stack = np.cumsum(y, axis=0) 
    ax3.fill_between(x, 0, y_stack[0,:], facecolor="#CC6666", alpha=.7)
    ax3.fill_between(x, y_stack[0,:], y_stack[1,:], facecolor="#1DACD6", alpha=.7)
    ax3.fill_between(x, y_stack[1,:], y_stack[2,:], facecolor="#6E5160")
    
    plt.show()

bubuko.com,布布扣

stackplot

标签:style   blog   http   color   for   sp   div   on   2014   

原文地址:http://www.cnblogs.com/hluo/p/4074343.html

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