I have data that looks like below. The Date/Time
field is in %m-%d-%Y %H:%M:%S
format.
Date/Time Utilization
04-01-2020 10:00:00 10
04-01-2020 10:10:00 20
04-01-2020 10:20:00 50
04-01-2020 10:30:00 10
04-02-2020 15:30:00 20
04-02-2020 15:40:00 10
04-02-2020 15:50:00 10
04-07-2020 23:40:00 40
04-07-2020 23:50:00 50
I want to plot this in Matplotlib, with x-axis as the date/time and y-axis as the utilization.
When I plot this, each of these 10 minute intervals are all squished together in the X-Axis (screenshot below):
My code for above is this:
def plot_graph(utilization_map):
utilization_array = []
date_array = []
for each_time in utilization_map:
utilization = utilization_map[each_time]
utilization_array.append(utilization)
human_time = convert_epoch_to_datetime_for_plots(each_time) # This converts the epoch time in %m-%d-%Y %H:%M:%S format
date_array.append(human_time)
x_axis = date_array
y_axis = utilization_array
plt.plot(x_axis, y_axis, color='b')
plt.title("Utilization")
plt.xlabel("Days")
plt.ylabel("Percent of Utilization")
plt.legend()
plt.show()
Question: I want to plot it in a way that the X-axis labels show only in %m-%d
or %m-%d-%Y
format and with daily intervals instead of 10 minutes, so all the times are not mushed together in the X-axis. How do I do this?