zoukankan      html  css  js  c++  java
  • matplotlib locators

    2020-03-23 17:59:59  -- Edit by yangray

    The Locator class is the base class for all tick locators. The locators
    handle autoscaling of the view limits based on the data limits, and the
    choosing of tick locations.
    --- matplotlib document

    Tips: To control the major and minor tick label formats, use one of the
    following methods::
    ax.xaxis.set_major_formatter(xmajor_formatter)
    ax.xaxis.set_minor_formatter(xminor_formatter)
    ax.yaxis.set_major_formatter(ymajor_formatter)
    ax.yaxis.set_minor_formatter(yminor_formatter)


    Figure without locator:

    #!/usr/bin/python
    # _*_ Coding: Utf-8 _*_
    
    import matplotlib.pyplot as plt
    import numpy as np
    import random
    from matplotlib.ticker import *
    
    t = [str(i) for i in range(40)]
    s = [36 + random.randint(0, 8) for i in range(40)]
    
    fig, axes = plt.subplots()
    
    axes.plot(t, s, 'go-', markersize=1, linewidth=0.6)
    axes.tick_params(axis='x', labelsize=8)  # tick_params
    axes.set_xticks(t)  # set ticks
    
    plt.show()
    
    
    • MaxNLocator
    
    

        Select no more than N intervals at nice locations. default_params = dict(nbins=10, steps=None, integer=False, symmetric=False, prune=None, min_n_ticks=2)

    
    

    maxNLocator = MaxNLocator(nbins=8)  # max N (divisions)
    

     

    maxNLocator = MaxNLocator(steps=[1, 2, 4, 5, 10])  # where the values are acceptable tick multiples
    

     

    maxNLocator = MaxNLocator(min_n_ticks=5) # minimum number of ticks

       other params: [integer]  If True, ticks will take only integer values

             [symmetricIf True, autoscaling will result in a range symmetric about zero

             [prune] ['lower' | 'upper' | 'both' | None]  Remove edge ticks
    • MultipleLocator

      

    multipleLocator = MultipleLocator(6)  # Set a tick on each integer multiple of a base within the view interval
    
    • FixedLocator

    fixedLocator = FixedLocator([1, 3, 5, 7, 15], nbins=7)  # fixed index (ticks <= nbins +1)
    
    • IndexLocator

    indexLocator = IndexLocator(5, 2)  # 
    
    • AutoMinorLocator

    autoMinor = AutoMinorLocator(5)  # generate minor locs with the number of subdivisions (must be on linear type locator)
    
      
    
    
  • 相关阅读:
    js json和对象互相转换
    github配置和git学习
    sea.js,spm学习
    less学习-语法(二)
    less学习-浏览器端编译(一)
    grunt-mac上安装运行构建工具的总结(一)
    Advice from an Old Programmer
    scikit-FEM-例2-用Morley元在方形区域上解板弯曲问题
    scikit-FEM-例1-求解Possion边值问题
    在shell脚本中调用sqlplus 分类: H2_ORACLE 2013-06-23 13:01 1437人阅读 评论(0) 收藏
  • 原文地址:https://www.cnblogs.com/exploer/p/12553881.html
Copyright © 2011-2022 走看看