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)
    
      
    
    
  • 相关阅读:
    mysql 统计新增每天数据
    Oracle dg下掉一个从库
    rman全备脚本
    Linux Shell 统计一(行列)数值的总和及行、列转换
    pt工具加字段脚本
    MySQL慢日志切割邮件发送脚本
    MySQL主从复制邮件报警脚本
    读书清单
    数据库学习笔记
    JAVAEE学习笔记
  • 原文地址:https://www.cnblogs.com/exploer/p/12553881.html
Copyright © 2011-2022 走看看