【Matplotlib】设置刻度(1)
刻度设置
参考文档:
以xticks为例:
matplotlib.pyplot.xticks(*args, **kwargs)
获取或者设置当前刻度位置和文本的 x-limits:
# return locs, labels where locs is an array of tick locations and
# labels is an array of tick labels.
locs, labels = xticks()
# set the locations of the xticks
xticks( arange(6) )
# set the locations and labels of the xticks
xticks( arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue') )
关键字 args ,如果有其他的参数则是 Text 属性。例如,旋转长的文本标注。
xticks( arange(12), calendar.month_name[1:13], rotation=17 )
参考文档
Axis containers
matplotlib.axis.Axis对象负责刻度线、格网线、刻度标注和坐标轴标注的绘制工作。你可以设置y轴的左右刻度或者x轴的上下刻度。 Axis 也存储了用于自动调整,移动和放缩的数据和视觉间隔;同时 Locator 和 Formatter 对象控制着刻度的位置以及以怎样的字符串呈现。
每一个 Axis 对象包含一个 label 属性以及主刻度和小刻度的列表。刻度是 XTick 和 YTick 对象,其包含着实际线和文本元素,分别代表刻度和注释。因为刻度是根据需要动态创建的,你应该通过获取方法 get_major_ticks() 和 get_minor_ticks()以获取主刻度和小刻度的列表。尽管刻度包含了所有的元素,并且将会在下面代码中涵盖,Axis 方法包含了获取方法以返回刻度线、刻度标注和刻度位置等等:
In [285]: axis = ax.xaxis
In [286]: axis.get_ticklocs()
Out[286]: array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9.])
In [287]: axis.get_ticklabels()
Out[287]: <a list of 10 Text major ticklabel objects>
# note there are twice as many ticklines as labels because by
# default there are tick lines at the top and bottom but only tick
# labels below the xaxis; this can be customized
In [288]: axis.get_ticklines()
Out[288]: <a list of 20 Line2D ticklines objects>
# by default you get the major ticks back
In [291]: axis.get_ticklines()
Out[291]: <a list of 20 Line2D ticklines objects>
# but you can also ask for the minor ticks
In [292]: axis.get_ticklines(minor=True)
Out[292]: <a list of 0 Line2D ticklines objects>
【Matplotlib】设置刻度(1)的更多相关文章
- 【Matplotlib】 刻度设置(2)
Tick locating and formatting 该模块包括许多类以支持完整的刻度位置和格式的配置.尽管 locators 与主刻度或小刻度没有关系,他们经由 Axis 类使用来支持主刻度和小 ...
- 使用matplotlib的示例:调整字体-设置刻度、坐标、colormap和colorbar等
使用matplotlib的示例:调整字体-设置刻度.坐标.colormap和colorbar等 2013-08-09 19:04 27805人阅读 评论(1) 收藏 举报 分类: Python(71 ...
- matplotlib 坐标轴刻度能见度问题
matplotlib 画图时如果图像太大就会挡住了坐标轴,刻度就看不到了.可以利用zorder设置level,level越小越先绘制. 例子: 1 import matplotlib.pyplot a ...
- matplotlib坐标轴刻度-【老鱼学matplotlib】
本节主要讲述如何对坐标轴的刻度字体大小以及背景色进行修改. 例如: import numpy as np import pandas as pd import matplotlib.pyplot as ...
- Matplotlib 设置
# 导入相关模块 import matplotlib.pyplot as plt import numpy as np 设置 figure Matplotlib 绘制的图形都在一个默认的 figure ...
- matplotlib 设置图形大小时 figsize 与 dpi 的关系
matplotlib 中设置图形大小的语句如下: fig = plt.figure(figsize=(a, b), dpi=dpi) 其中: figsize 设置图形的大小,a 为图形的宽, b 为图 ...
- matplotlib设置颜色、标记、线条,让你的图像更加丰富
今天是数据处理专题的第11篇文章,我们继续来介绍matplotlib这个包的使用方法. 在上一篇文章当中我们介绍了matplotlib当中subplot的概念以及用法,今天我们将会来介绍matplot ...
- matplotlib 设置标题 xy标题等
import matplotlib.pyplot as plt import matplotlib as mpl baseclass=[1,2,3,4] name = ['class1','class ...
- matplotlib设置中文标签
import matplotlib.pyplot as plt plt.rcParams['font.sans-serif']=['SimHei']
随机推荐
- Hanoi塔
2016-03-19 17:01:35 问题描述: 假设有三个命名为 A B C 的塔座 ,在塔座A上插有n个直径大小不相同,由小到大编号为1 ,2 ,3 ,··· ,n的圆盘,要求将A座上的圆盘移至 ...
- Android外部SD卡的读取
package com.kevin.writeorreadfile1_1; import android.app.Activity; import android.bluetooth.le.ScanF ...
- maven总结2
依赖 maven版本:apache-maven-3.1.1 IDE: springsource 默认支持maven集成 若使用的是eclipse,则需要先安装m2ec ...
- Git 详解
1. Git 1.1. Git是何方神圣? Git是用C语言开发的分布版本控制系统.版本控制系统可以保留一个文件集合的历史记录,并能回滚文件集合到另一个状态(历史记录状态).另一个状 态可以是不同的文 ...
- .Net core Linux环境安装
10月份的时候在自己电脑上搭了开发环境,当时跑完Welcome后就搁置了一段时间,最近有一个小项目要正式采用core来开发并部署在linux环境下,于是在Linux上也搭建一个运行环境. 虽然不经常使 ...
- gridpanel分组汇总
[ExtJS5学习笔记]第三十节 sencha extjs 5表格gridpanel分组汇总 2015-05-31 86 本文地址:http://blog.csdn.net/sushengmi ...
- 【转】【WPF】资源读取 URI
一开始看到WPF里面经常用如下语句来构造资源文件Uri: Uri uri = new Uri("/AssemblyName;component/image.png"); 我还以为这 ...
- ruby on rails gem install pg时无法安装
gem install pg -v '0.18.2' Building native extensions. This could take a while... ERROR: Error insta ...
- 在opencv3中的机器学习算法练习:对OCR进行分类
OCR (Optical Character Recognition,光学字符识别),我们这个练习就是对OCR英文字母进行识别.得到一张OCR图片后,提取出字符相关的ROI图像,并且大小归一化,整个图 ...
- 《JavaScript高级程序设计》chapter 1: javascript 简介
1.2.2 文档对象模型 DHTML的出现让开发人员无需重新加载页面就可以修改其外观了. 1.2.3 浏览器对象模型(BOM) BOM真正与众不同的地方在于他作为javascript实 ...