博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python之matplotlib学习(三)
阅读量:4482 次
发布时间:2019-06-08

本文共 1399 字,大约阅读时间需要 4 分钟。

例子11-1:横坐标时间的处理

from matplotlib.dates import datestr2num,DateFormatterimport matplotlib.dates as datesfig,ax=plt.subplots()formatter = DateFormatter('%H')#设置时间间隔ax.xaxis.set_major_locator(dates.HourLocator(byhour=range(24), interval=4))ax.xaxis.set_major_formatter(formatter)ax.plot_date(datestr2num(time_list),iops_list,'-',label='iops')

 

输出结果:

例子11-2:纵坐标处理

原图:

 

从图上看纵坐标区间过大,不利用查看。

改成200为步长:

import matplotlib.ticker as tkax.yaxis.set_major_locator(tk.MultipleLocator(200))

 

输出结果:

例子11-3:纵坐标处理——按照分钟进行间隔

如下是原始输出的图

时间轴每5分钟一次,过于太密,想改成如下效果:

按照分钟级别进行汇总,代码修改的地方如下:

import matplotlib.dates as datesax.xaxis.set_major_locator(dates.MinuteLocator(byminute=range(60), interval=10))>>> import matplotlib.dates as dates>>> help(dates)#查看帮助文档Here are all the date tickers:            * :class:`MinuteLocator`: locate minutes            * :class:`HourLocator`: locate hours            * :class:`DayLocator`: locate specifed days of the month            * :class:`WeekdayLocator`: Locate days of the week, eg MO, TU            * :class:`MonthLocator`: locate months, eg 7 for july            * :class:`YearLocator`: locate years that are multiples of base         |  ----------------------------------------------------------------------     |  Data and other attributes inherited from DateLocator:     |       |  hms0d = {'byhour': 0, 'byminute': 0, 'bysecond': 0}

 

 

转载于:https://www.cnblogs.com/gsblog/p/3426054.html

你可能感兴趣的文章
一则小脚本(工作中用)
查看>>
软件工程结对作业
查看>>
Keil 4.0 生成bin文件
查看>>
sql语句的进化--hibernate篇
查看>>
python爬虫之cookie
查看>>
11.超市收银系统的项目
查看>>
2017年5月29号课堂笔记
查看>>
HDU4247【瞎搞】
查看>>
lightoj 1125【背包·从n个选m个】
查看>>
HDU 1243 反恐训练营(最长公共序列)
查看>>
mysql数据库隔离级别
查看>>
(六)buildroot使用详解
查看>>
chrome修改UserAgent,调试
查看>>
Source Insight4.0 试用。。试用。。试用。。
查看>>
python循环for,range,xrange;while
查看>>
hadoop的节点间的通信
查看>>
HashMap
查看>>
mysql 主从 重新同步
查看>>
论如何制做一个工程APP的测试内容
查看>>
如何通过Java启动linux脚本
查看>>