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
[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的更多相关文章
- 【Matplotlib】详解图像各个部分
首先一幅Matplotlib的图像组成部分介绍. 在matplotlib中,整个图像为一个Figure对象.在Figure对象中可以包含一个或者多个Axes对象.每个Axes(ax)对象都是一个拥有自 ...
- 【Matplotlib】 刻度设置(2)
Tick locating and formatting 该模块包括许多类以支持完整的刻度位置和格式的配置.尽管 locators 与主刻度或小刻度没有关系,他们经由 Axis 类使用来支持主刻度和小 ...
- 【Python】一份非常好的Matplotlib教程
Matplotlib 教程 本文为译文,原文载于此,译文原载于此.本文欢迎转载,但请保留本段文字,尊重作者和译者的权益.谢谢.: ) 介绍 Matplotlib 可能是 Python 2D-绘图领域使 ...
- 基于matplotlib的数据可视化 - 笔记
1 基本绘图 在plot()函数中只有x,y两个量时. import numpy as np import matplotlib.pyplot as plt # 生成曲线上各个点的x,y坐标,然后用一 ...
- python3绘图示例6-2(基于matplotlib,绘图流程介绍及设置等)
#!/usr/bin/env python# -*- coding:utf-8 -*- import os import numpy as npimport matplotlib as mpltfro ...
- python3绘图示例6-1(基于matplotlib,绘图流程介绍及设置等)
#!/usr/bin/env python# -*- coding:utf-8 -*- import os import pylab as pyimport numpy as npfrom matpl ...
- Python 绘图与可视化 matplotlib(下)
详细的参考链接:更详细的:https://www.cnblogs.com/zhizhan/p/5615947.html 图像.子图.坐标轴以及记号 Matplotlib中图像的意思是打开的整个画图窗口 ...
- matplotlib PyQt5 nivigationBar 中pan和zoom功能的探索
为matplotlib生成的图添加编辑条,我们导入NavigationToolbar2QT from matplotlib.backends.backend_qt5agg import Navigat ...
- python安装numpy、scipy和matplotlib等whl包的方法
最近装了python和PyCharm开发环境,但是在安装numpy和matplotlib等包时出现了问题,现总结一下在windows平台下的安装方法. 由于现在找不到了工具包新版本的exe文件,所以采 ...
随机推荐
- SSM框架学习笔记
管理部门: --Spring + SpringMVC+MyBatis 1.index.jsp--->SpringMVC(Servlet) 接受客户端的请求,读取页面的值,回传到页面 2.Myba ...
- python的C扩展调用,使用原生的python-C-Api
1.在文件第一行包含python调用扩展的头文件 #include <Python.h> 2.用原生C写好需要调用的函数 int add_one(int a){ ; } 3.用python ...
- stm32的hall库新建模板编译错误: #error "Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file)"的处理
在stm32f1xx.h file文件中找到如下代码: /* Uncomment the line below according to the target STM32L device used i ...
- ijkplayer中遇到的问题汇总
在做音频播放的时候,很多公司使用的是开源的ijkplayer播放器,ijkplayer底层是基于ffmpeg,在某机型上面可能常常遇到各种问题.今天整理了大家在使用ijkplayer中遇到的问题,以及 ...
- thinkphp5.0.*命令执行批量脚本
import requests import Queue import threading import time user_agent = "Mozilla/5.0 (Windows NT ...
- Python+Selenium+Unittest编写超链接点击测试用例
测试功能:博客园首页网站分类的一级菜单链接和二级菜单链接的点击. 遇到的问题: 1.循环点击二级菜单时,点击了一个一级菜单下的第一个二级菜单后,页面会刷新,再定位同一个一级菜单次下的第二个二级菜单时, ...
- CF1327A Sum of Odd Integers 题解
原题链接 简要题意: 多组数据,问能否把 \(n\) 分为 \(k\) 个 不同的 正奇数之和. 盲猜数学结论题. 只要考虑两个问题: \(n\) 的大小是否足够. \(n\) 的奇偶性是否满足. 对 ...
- In Triangle Test / To Left Test
2020-01-09 14:51:29 如何高效的判断一个点是否是包含在一个三角形的内部是计算几何里的一个基础问题. In Triangle Test问题也可以用来解决计算几何里的一个基础问题就是 凸 ...
- Qt 事件使用示例 (一)
Qt 事件使用示例,以一个常见的使用来说明:QLabel 当鼠标滑过时改变颜色. 事先说明要想实现这一功能有很多种方法,如Qss实现,本文使用Qt事件的方式来实现. 第一步,我们得实现一个从QLabe ...
- Typora+markdown 最常用语法教程
Typora+markdown 最常用语法教程(by 程序员宝藏) Typora+markdown 最常用语法教程(by 程序员宝藏) 请先配置推荐配置(文件->偏好设置): 文章目录 Typo ...
