【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']
随机推荐
- 关于CSS中的字体尺寸设置 em rem等
常用单位 在CSS中可以用很多不同的方式来设定字体的尺寸.一般来说,这些单位被分成两大类:绝对单位(absolute)和相对单位(relative). 绝对单位在大多数情况下是相对于某些实际量度而言的 ...
- UVALive 6181
模拟题,注意细节.. #include <iostream> #include<stdio.h> #include<math.h> #include<stri ...
- openstack通过salt-cloud创建虚拟机
saltstack有三大功能:远程执行.配置管理.云管理:saltstack的云管理就是通过salt-cloud完成的,salt-cloud是基于openstack来做的:salt-cloud能够管理 ...
- 本地ip被劫持,初始化hosts文件,及其作用与说明
# Copyright (c) 1993-2009 Microsoft Corp.## This is a sample HOSTS file used by Microsoft TCP/IP for ...
- 墙国内新建Rails应用的要点(windows 7环境, Rails 4.2.0)
1. 使用rails new 命令创建完的应用在自动执行bundle install不会成功,根据出错提示,判断原因有可能是被墙与https的证书的安全性问题. 作为开发环境,选用绕开的办法,在目录 ...
- MySQL初始化简单优化
1,yum 2,源码 3,二进制 4,源码+yum 不管哪种方式装完成数据库,都需要对数据库做一些优化. 优化数据库 mysql> select host,user from mysql.us ...
- Contains Duplicate II
Given an array of integers and an integer k, find out whether there there are two distinct indices i ...
- CUDA安装及配置:Windows 7 64位环境
最近又有新的项目要做了,这次是关于CUDA---多核高性能计算的问题,所以最近一直在学习CUDA的编程问题,昨天安装软件完毕,运行第一个程序的时候还是遇到很多问题.所以这里给大家一起分享一下, 有和我 ...
- ActionBar在Android2.x的实现,类似新版微信界面。
ActionBar完美兼容Android4.x的机型,虽然现在Android2.x的系统越来越少,还有有一部分人使用的仍是2.x的系统,所以我们还得考虑着兼容性问题. 对比图: Test例子与微信的对 ...
- WireShark系列: 使用WireShark过滤条件抓取特定数据流(zz)
应用抓包过滤,选择Capture | Options,扩展窗口查看到Capture Filter栏.双击选定的接口,如下图所示,弹出Edit Interface Settints窗口. 下图显示了Ed ...