zoukankan      html  css  js  c++  java
  • stackplot

    # -*- 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()

  • 相关阅读:
    zTree学习笔记之展开树和收起树
    添优--史上超级全面的前端面试题大集合
    springboot2.0整合jpa
    Idea快捷键
    实用工具收藏
    nginx
    SQLServer锁的机制
    centos安装jenkins
    java8
    前端开发收藏
  • 原文地址:https://www.cnblogs.com/hluo/p/4074343.html
Copyright © 2011-2022 走看看