Я рисую фрейм данных, используя Matplotlib 3.3.0
.
index
фрейма данных - это объект datetime
в следующем формате:
2018-05-29 08:09:00
(т.е. year-month-day hour:minute:second
)
Как увеличить временной интервал Ежечасно или Ежедневно или Еженедельно или Ежемесячно ? Я хочу иметь несколько QPushButton
, чтобы пользователь мог увеличить или панорамировать до временного отрезка продолжительностью дня или недели, месяца или часа, как показано на изображение.
I plot the data-frame as following:
self.canvas.axes.plot(self.df.index, self.df.loc[:, self.comboBox.currentText()], linestyle="None", marker='.')
self.label = self.canvas.axes.set_xlabel('Time', fontsize=9)
self.label = self.canvas.axes.set_ylabel('Temperature - k [°C]', fontsize=9)
self.canvas.axes.legend('Temperature - k [°C]', bbox_to_anchor=(0., 1.02, 1., .102), loc='upper center', ncol=8, mode=None, borderaxespad=0.)
The second problem is that the legend isn't shown completely. Only its first character is displayed. How to fix it?
Updated:
I tried plotting the data-frame based on a time element as X-axis like:
self.canvas.axes.plot(self.new_df.index.hour, self.new_df.loc[:, self.comboBox.currentText()])
But, since the values of hour
s are repeating over each day and over the whole data-frame, then the plot isn't drawn correctly like below picture:
данные нарисованы неправильно из-за повторяющихся значений по оси X