matplotlib formatters
Tick formatting is controlled by classes derived from Formatter. The formatter
operates on a single tick value and returns a string to the axis. -- 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 formatter:
#!/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)]
# t = [str(10**i) for i in range(-5, 5)] # test data for scaler, eng formatter
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 fig.tight_layout()
plt.show()
- NullFormatter

nullFormatter = NullFormatter() # null formatter
FixedFormatter

fixedFormatter = FixedFormatter(['1', 'show', '2', 'to', '3', 'you', '4', 'yeah']) # fixed formatter
IndexFormatter

indexFormatter = IndexFormatter(['1', 'show', '2', 'to', '3', 'you']) # index deceid
FormatStrFormatter

formatStrFormatter = FormatStrFormatter("%dth") # Use an old-style ('%' operator) format string to format the tick.
StrMethodFormatter

strMethodFormatter = StrMethodFormatter("{x}|{pos}") # `x` and `pos` are passed to `str.format` as keyword arguments
PercentFormatter

percentFormatter = PercentFormatter(xmax=50, decimals=None, symbol='%', is_latex=False) # Format numbers as a percentage
funcFormatter

def my_formatter_func(x, pos = None):
if x % 6 == 0:
return "|"
else:
return "1" funcFormatter = FuncFormatter(func=my_formatter_func) # user-defined func
matplotlib formatters的更多相关文章
- 【Python】一份非常好的Matplotlib教程
Matplotlib 教程 本文为译文,原文载于此,译文原载于此.本文欢迎转载,但请保留本段文字,尊重作者和译者的权益.谢谢.: ) 介绍 Matplotlib 可能是 Python 2D-绘图领域使 ...
- 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 ...
- logging,numpy,pandas,matplotlib模块
logging模块 日志总共分为以下五个级别,这五个级别自下而上进行匹配debug->info->warning->error->critical,默认的最低级别warning ...
- Python 绘图与可视化 matplotlib(下)
详细的参考链接:更详细的:https://www.cnblogs.com/zhizhan/p/5615947.html 图像.子图.坐标轴以及记号 Matplotlib中图像的意思是打开的整个画图窗口 ...
- python安装numpy、scipy和matplotlib等whl包的方法
最近装了python和PyCharm开发环境,但是在安装numpy和matplotlib等包时出现了问题,现总结一下在windows平台下的安装方法. 由于现在找不到了工具包新版本的exe文件,所以采 ...
- matplotlib 高级用法实例--共享x轴
http://localhost:8888/notebooks/duanqs/matplotlib_advanced_example.ipynb 我不会弄呀, 刚才从matplotlib文档里吧示例用 ...
- Python matplotlib笔记
可视化的工具有很多,如Tableau,各种JS框架,我个人感觉应该是学JS最好,因为JS不需要环境,每个电脑都有浏览器,而像matplotlib需要Python这样的开发环境,还是比较麻烦的,但是毕竟 ...
- Matplotlib——第一章轻松画个图
首先安装matplotlib,使用pip install matplotlib.安装完成后在python的命令行敲入import matplotlib,如果没问题,说明安装成功可以开始画图了. 看好了 ...
随机推荐
- java-接口(新手)
//创建的一个包名. package jiekou; //接口方法. //创建一个接口并且起名字. public interface JK { //抽象的返回值.(具体功能未定义,需要自己定义) ab ...
- [Alg] 文本匹配-多模匹配-AC自动机
1. 简介 AC自动机是一种多模匹配的文本匹配算法. 如果采用naive的方法,即依次比较文本串s中是否包含模式串p1, p2,...非常耗时.考虑到这些模式串中可能具有相同子串,可以利用已经比较过的 ...
- kerberos系列之hdfs&yarn认证配置
一.安装hadoop 1.解压安装包重命名安装目录 [root@cluster2_host1 data]# tar -zxvf hadoop-2.7.1.tar.gz -C /usr/local/ [ ...
- mysql 更换数据目录
mysql 更换数据目录 1.停止MySql服务: /etc/rc.d/init.d/mysql stop 或者 service mysql stop 2.确认MySql原来的数据目录,查找datad ...
- ADO.NET 的使用(一)
一.ADO.NET概要 ADO.NET 是一组向 .NET Framework 程序员公开数据访问服务的类. ADO.NET 为创建分布式数据共享应用程序提供了一组丰富的组件. 它提供了对关系数据.X ...
- MyBatis框架——多表查询
MyBatis多表查询, 从表中映射主表,使用 association 标签,通过设置 javaType 属性关联实体类: 主表映射从表,使用 collection 标签,通过 ofType 属性关联 ...
- Loadrunner 11安装和破解
一.安装环境和文件准备 1.操作系统:Windows Server 2008 R2 Enterprise: 2.loadrunner版本:loadrunner 11: 3.安装浏览器:火狐39.0: ...
- 《JavaScript 模式》读书笔记(4)— 函数4
这篇文章我们主要来学习下即时对象初始化.初始化时分支.函数属性-备忘模式以及配置对象.这篇的内容会有点多. 六.即时对象初始化 保护全局作用域不受污染的另一种方法,即时对象初始化模式.这种模式使用带有 ...
- Visual Studio2019+OpenCV3.4.9环境搭建
让人头疼的vs2019+opencv环境配置 准备: visual studio2019: opencv 3.4.9: 耐心: 说明:vs2019属性管理器没有Microsoft.Cpp.x64.us ...
- python3读取excel实战
'''参数化'''import xlrd,xlwt,jsonfrom api实现.读取参数化接口说明 import TestApiclass ReadFileData: def __init__(se ...
