好吧,因为没有发布代码可言,我决定快速举个例子:
import numpy as np
# create a sample data array
data = np.array([
['data', 7122, '24/02/2023 15:51', 22.06071, 22],
['data', 7122, '24/02/2023 15:22', 22.022, 22],
['data', 7122, '24/02/2023 15:00', 22.011, 22],
# add more rows here
])
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
# now plot the data with row 2 as x-axis and row 3 as y-axis
# convert the np array to a pandas dataframe
df = pd.DataFrame(data)
# convert the 3rd column to datetime
df[2] = pd.to_datetime(df[2])
# plot the data
fig, ax = plt.subplots()
ax.plot(df[2], df[3])
# set the x-axis to be date
ax.xaxis.set_major_locator(mdates.DayLocator())
ax.xaxis.set_major_formatter(mdates.DateFormatter('%d/%m/%Y %H:%M'))
# set the x-axis label
ax.set_xlabel('Time')
# rotate the x-axis labels
plt.setp(ax.get_xticklabels(), rotation=45, ha="right", rotation_mode="anchor")
# set the y-axis label
ax.set_ylabel('Room Avr')
# set the title
ax.set_title('Temperature over time')
# show the plot
plt.show()