matplotlib刻度
2012-04-09 18:30
453 查看
点击打开链接
#!/usr/bin/env python #-*- coding: utf-8 -*- #--------------------------------------------------- #演示MatPlotLib中设置坐标轴主刻度标签和次刻度标签. #对于次刻度显示,如果要使用默认设置只要matplotlib.pyplot.minorticks_on() #--------------------------------------------------- from pylab import * from matplotlib.ticker import MultipleLocator, FormatStrFormatter #--------------------------------------------------- xmajorLocator = MultipleLocator(20) #将x主刻度标签设置为20的倍数 xmajorFormatter = FormatStrFormatter('%5.1f') #设置x轴标签文本的格式 xminorLocator = MultipleLocator(5) #将x轴次刻度标签设置为5的倍数 ymajorLocator = MultipleLocator(0.5) #将y轴主刻度标签设置为0.5的倍数 ymajorFormatter = FormatStrFormatter('%1.1f') #设置y轴标签文本的格式 yminorLocator = MultipleLocator(0.1) #将此y轴次刻度标签设置为0.1的倍数 t = arange(0.0, 100.0, 1) s = sin(0.1*pi*t)*exp(-t*0.01) ax = subplot(111) #注意:一般都在ax中设置,不再plot中设置 plot(t,s,'--r*') #设置主刻度标签的位置,标签文本的格式 ax.xaxis.set_major_locator(xmajorLocator) ax.xaxis.set_major_formatter(xmajorFormatter) ax.yaxis.set_major_locator(ymajorLocator) ax.yaxis.set_major_formatter(ymajorFormatter) #显示次刻度标签的位置,没有标签文本 ax.xaxis.set_minor_locator(xminorLocator) ax.yaxis.set_minor_locator(yminorLocator) ax.xaxis.grid(True, which='major') #x坐标轴的网格使用主刻度 ax.yaxis.grid(True, which='minor') #y坐标轴的网格使用次刻度 show() ##########################################################http://blog.csdn.net/rumswell/article/details/6571005
相关文章推荐
- matplotlib(刻度,刻度线长短位置相关设置)
- Python利用matplotlib.pyplot绘图时如何设置坐标轴刻度
- python matplotlib绘图,修改坐标轴刻度为文字
- matplotlib tricks(关闭坐标刻度、坐标轴不可见)
- python matplotlib.pyplot画图设置刻度
- 【Matplotlib】 刻度设置(2)
- 使用matplotlib的示例:调整字体-设置刻度、坐标、colormap和colorbar等
- 【Matplotlib】 刻度设置(2)
- matplotlib坐标轴刻度-【老鱼学matplotlib】
- 演示MatPlotLib中如何设置坐标轴主刻度标签和次刻度标签
- python matplotlib绘图,修改坐标轴刻度为文字的实例
- python matplotlib绘图设置坐标轴刻度、文本
- 用matplotlib设置标题、轴标签、刻度标签以及添加图例
- 学习python中matplotlib绘图设置坐标轴刻度、文本
- matplotlib去掉坐标轴刻度
- 使用matplotlib的示例:调整字体-设置刻度、坐标、colormap和colorbar等
- python matplotlib 画图刻度、图例等字体、字体大小设置
- 【原】在Matplotlib绘图过程中设置X轴的刻度和显示文本
- matplotlib命令与格式:tick刻度对象命令合集
- python matplotlib 画图刻度、图例等字体、字体大小设置