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

         [symmetric]  If 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)
  
												

matplotlib locators的更多相关文章

  1. 【Matplotlib】详解图像各个部分

    首先一幅Matplotlib的图像组成部分介绍. 在matplotlib中,整个图像为一个Figure对象.在Figure对象中可以包含一个或者多个Axes对象.每个Axes(ax)对象都是一个拥有自 ...

  2. 【Matplotlib】 刻度设置(2)

    Tick locating and formatting 该模块包括许多类以支持完整的刻度位置和格式的配置.尽管 locators 与主刻度或小刻度没有关系,他们经由 Axis 类使用来支持主刻度和小 ...

  3. 【Python】一份非常好的Matplotlib教程

    Matplotlib 教程 本文为译文,原文载于此,译文原载于此.本文欢迎转载,但请保留本段文字,尊重作者和译者的权益.谢谢.: ) 介绍 Matplotlib 可能是 Python 2D-绘图领域使 ...

  4. 基于matplotlib的数据可视化 - 笔记

    1 基本绘图 在plot()函数中只有x,y两个量时. import numpy as np import matplotlib.pyplot as plt # 生成曲线上各个点的x,y坐标,然后用一 ...

  5. python3绘图示例6-2(基于matplotlib,绘图流程介绍及设置等)

    #!/usr/bin/env python# -*- coding:utf-8 -*- import os import numpy as npimport matplotlib as mpltfro ...

  6. python3绘图示例6-1(基于matplotlib,绘图流程介绍及设置等)

    #!/usr/bin/env python# -*- coding:utf-8 -*- import os import pylab as pyimport numpy as npfrom matpl ...

  7. Python 绘图与可视化 matplotlib(下)

    详细的参考链接:更详细的:https://www.cnblogs.com/zhizhan/p/5615947.html 图像.子图.坐标轴以及记号 Matplotlib中图像的意思是打开的整个画图窗口 ...

  8. matplotlib PyQt5 nivigationBar 中pan和zoom功能的探索

    为matplotlib生成的图添加编辑条,我们导入NavigationToolbar2QT from matplotlib.backends.backend_qt5agg import Navigat ...

  9. python安装numpy、scipy和matplotlib等whl包的方法

    最近装了python和PyCharm开发环境,但是在安装numpy和matplotlib等包时出现了问题,现总结一下在windows平台下的安装方法. 由于现在找不到了工具包新版本的exe文件,所以采 ...

随机推荐

  1. 小白学 Python 数据分析(17):Matplotlib(二)基础操作

    人生苦短,我用 Python 前文传送门: 小白学 Python 数据分析(1):数据分析基础 小白学 Python 数据分析(2):Pandas (一)概述 小白学 Python 数据分析(3):P ...

  2. File的功能--> 获取功能-->所有的根目录 | 创建文件功能,但是如果文件已经存在-->不再创建(新手)

    //导入的包.import java.io.File;import java.io.FileFilter;import java.io.IOException; // 获取功能-->所有的根目录 ...

  3. appium移动自动化详解

    1移动自动化简介 移动自动化就是通过代码来控制手机,模拟人的动作,对手机进行一些点击,输入等操作,那python代码如何能控制到手机呢?目前的思路应该是python代码->Appium-pyth ...

  4. Systematic comparison of strategies for the enrichment of lysosomes by data independent acquisition 通过DIA技术系统比较各溶酶体富集策略 (解读人:王欣然)

    文献名:Systematic comparison of strategies for the enrichment of lysosomes by data independent acquisit ...

  5. 强智教务系统验证码识别 OpenCV

    强智教务系统验证码识别 OpenCV 强智教务系统验证码验证码字符位置相对固定,比较好切割 找准切割位置,将其分为四部分,匹配自建库即可,识别率近乎100%,如果觉得不错,点个star吧

  6. 「面试指南」解读JavaScript原始数据类型

    JavaScript 有 7 种原始数据类型: String(字符型) Number(数值型) Boolean(布尔值型) Undefined Null Object(对象型) Symbol(符号型, ...

  7. C语言学生管理系统

    想练习一下链表,所以就有了这个用C写的学生管理系统 没有把它写入文件,才不是因为我懒哈哈哈,主要是为了练习链表的 #include<stdio.h> #include<stdlib. ...

  8. windows常用系统命令

    dir指定要列出的驱动器.目录和/或文件 显示当前路径下的所有文件的绝对路径,包含子文件夹中的内容 dir /b / s /o:n /a:a /b 表示去除摘要信息,且顶格显示完整路径 /s 表示枚举 ...

  9. 【pytorch】改造resnet为全卷积神经网络以适应不同大小的输入

    为什么resnet的输入是一定的? 因为resnet最后有一个全连接层.正是因为这个全连接层导致了输入的图像的大小必须是固定的. 输入为固定的大小有什么局限性? 原始的resnet在imagenet数 ...

  10. 【笔记3-31】Python语言基础-字典dict

    创建字典 dict1 = {'k1': 'v1', 'k2': 'v2', 'k3': 'v3', 'k4': 'v4'} dict2 = dict(k1='v1', k2='v2', k3='v3' ...