• 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)
    
      
    
    
  • 相关阅读:
    几个有趣的在线设计网站搜集
    动物水池png+ico图标:pool
    看看3150亿美元叠起来有多高
    卡巴斯基免费key发布网站:kaspersky
    58个精品壁纸分享网站[精品]
    一套华丽的vista安装包png+ico图标:vistalike
    32个精品国外图文结合photoshop效果教程
    超酷背景笔刷[abr格式]:grunge
    针对MM的在线处理图片网站:Taaz
    如何设计web2.0的图标[两个photoshop web2.0样式asl下载]
  • 原文地址:https://www.cnblogs.com/exploer/p/12553881.html
Copyright © 2020-2023  润新知