pylot坐标自定义:仅显示时分坐标
在pylot中绘制图表时,横坐标通常采用datetime.datetime格式,显示年月日。然而,在某些场景下,用户可能只希望显示时分坐标,而无需年月日。
以下代码演示如何将datetime.time数据类型作为pylot图表的横坐标:
import pylot import datetime # 时间数据(仅包含时分) x = [datetime.time(10, 59), datetime.time(14, 59), datetime.time(16, 59), ...] # 人为设置年月日为相同日期 y_vals = [1, 2, 3, ...] dates = [] for _ in range(len(x)): dates.append(datetime.datetime(2023, 3, 8)) # 创建图表 fig = pylot.figure() fig.line(dates, y_vals, x_key=x) fig.show()
在这种方式下,图表将只显示时分坐标,而年月日将被保持为相同的值。
以上就是如何在Pylot中仅显示时分坐标?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号