1 Star 0 Fork 0

dingqiao/Flask_CaseCreate

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
zz.py 2.12 KB
一键复制 编辑 原始数据 按行查看 历史
dingqiao 提交于 2024-09-20 21:34 . update
import matplotlib.pyplot as plt
import numpy as np
# 定义时间点和对应的数据
time_points = ['00:00:00', '01:00:00', '02:00:00', '03:00:00', '04:00:00', '05:00:00',
'06:00:00', '07:00:00', '08:00:00', '09:00:00', '10:00:00', '11:00:00', '00:00:00', '01:00:00',
'02:00:00', '03:00:00', '04:00:00', '05:00:00',
'06:00:00', '07:00:00', '08:00:00', '09:00:00', '10:00:00', '11:00:00']
data = [5, 10, 8, 4, 25, 12, 6, 22, 17, 23, 9, 55, 5, 10, 8, 4, 25, 12, 6, 22, 17, 23, 9, 55]
# 创建图形和轴
fig, ax = plt.subplots(figsize=(10, 6))
# 计算时间点的中点位置
time_positions = np.arange(len(time_points)) + 0.5
# 绘制折线图,数据点落在时间区间的中点位置
ax.plot(time_positions, data, marker='o')
# 设置图形标题和轴标签
ax.set_title('Interval Line Plot from 00:00 to 12:00')
ax.set_xlabel('Time Intervals')
ax.set_ylabel('Data')
# # 设置 x 轴刻度和标签
# ax.set_xticks(np.arange(len(time_points)))
# ax.set_xticklabels(time_points, rotation=45)
num_ticks = round(len(time_points) // 8)
# num_ticks = int(num_ticks)
# 设置 x 轴刻度和标签,每隔 2 个时间点显示一个标签
ax.set_xticks(time_positions[::num_ticks])
ax.set_xticklabels(time_points[::num_ticks], rotation=0)
max_value = ((max(data) + 10) // 10 + 1) * 10
ax.set_ylim(0, max_value)
# 显示图形
plt.tight_layout()
plt.show()
# import psutil
#
# # 获取所有磁盘分区信息
# partitions = psutil.disk_partitions()
#
# for partition in partitions:
# try:
# partition_usage = psutil.disk_usage(partition.mountpoint)
# except PermissionError:
# # 可能会出现权限错误,忽略这些错误
# continue
#
# print(f"盘符: {partition.device}")
# print(f"挂载点: {partition.mountpoint}")
# print(f"文件系统类型: {partition.fstype}")
# print(f"总大小: {partition_usage.total / (1024**3):.2f} GB")
# print(f"已用大小: {partition_usage.used / (1024**3):.2f} GB")
# print(f"剩余大小: {partition_usage.free / (1024**3):.2f} GB")
# print(f"使用百分比: {partition_usage.percent}%")
# print("-" * 40)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/dingqiao1638105266/flask_-case-create.git
[email protected]:dingqiao1638105266/flask_-case-create.git
dingqiao1638105266
flask_-case-create
Flask_CaseCreate
master

搜索帮助