0

question: i have a series of datetime.time type data (a list or a pd.series, and i don't care about the date) as x-axis, and another series of data as y axis. then, how can i plot the the list of datetime.time as my x-axis with a range from (09:00 to 18:00) and step of 2 hours? e.g

import datetime
x = [datetime.time(hour=9,minute=0,second=0),datetime.time(hour=12,minute=3,second = 6),datetime.time(hour=14,minute=20,second=0)]
y=[1,2,3]

then how to plot the y value along with x as the x-axis with a step of 2 hours with a specified time range (e.g 08:00:00 - 18:00:00),the x-axis should be something like this: enter image description here

I was quite surprised that matplotlib does not offer api for such a simple and common situation.

  • Please provide some sample data and an example of the expected chart output. – Scott Boston Dec 28 '20 at 15:14
  • This question asks for every hour, but the principle is the same: [how to get ticks every hour?](https://stackoverflow.com/questions/48790378/how-to-get-ticks-every-hour). You should also have a look at the [matplotlib documentation.](https://matplotlib.org/3.1.1/api/dates_api.html). If this all fails, [provide an MCVE](https://stackoverflow.com/help/minimal-reproducible-example) so people can reproduce your problem and offer a solution. – Mr. T Dec 28 '20 at 15:14

0 Answers0