zoukankan      html  css  js  c++  java
  • plot sin 动态配置rc settings

    plot sin 动态配置rc settings

    • 坐标轴颜色
    • 线的颜色
    • 绘图前景色

    Code

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    import numpy as np
    import matplotlib
    import matplotlib.pyplot as plt
    
    # Data to be represented
    X = np.linspace(-np.pi,+np.pi,256)
    Y = np.sin(X)
    
    # Configuration via RC
    matplotlib.rc('axes', facecolor = 'grey')
    matplotlib.rc('axes', edgecolor = 'white')
    matplotlib.rc('xtick', color = 'white')
    matplotlib.rc('ytick', color = 'white')
    matplotlib.rc('figure', facecolor = 'grey')
    matplotlib.rc('savefig', facecolor = 'grey')
    
    # Actual plotting
    fig = plt.figure(figsize=(8,6), dpi=72)
    axes = plt.subplot(111)
    axes.plot(X,Y, color = 'yellow', linewidth=2, linestyle="-")
    axes.set_xlim(1.1*X.min(), 1.1*X.max())
    axes.set_ylim(1.1*Y.min(), 1.1*Y.max())
    
    axes.spines['bottom'].set_position(('data',0))
    axes.xaxis.set_ticks_position('bottom')
    axes.spines['left'].set_position(('data',0))
    axes.yaxis.set_ticks_position('left')
    axes.spines['top'].set_color('none')
    axes.spines['right'].set_color('none')
    
    plt.show()
    

    Keypoints

    matplotlib.rc('axes', facecolor = 'grey')
    rc-settings.png

    Result

    rc-settings-result.png

  • 相关阅读:
    (8)ftp配置文档
    (6)centos安装和解压
    (8)python tkinter-画布
    (7)python tkinter-菜单栏
    (6)python tkinter-容器、子窗体
    (5)python tkinter-单选、多选
    bzoj1096 [ZJOI2007]仓库建设
    hdu3507 Print Article(斜率DP优化)
    bzoj1996 [Hnoi2010]chorus 合唱队
    跳石头
  • 原文地址:https://www.cnblogs.com/xilifeng/p/3917205.html
Copyright © 2011-2022 走看看