代码拉取完成,页面将自动刷新
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)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。