0

First time posting, so bear with me. I've spent probably 15 hours trying to figure this out without avail.

I have a bunch of timestamp data in epoch format with millisecond units. Pressure/Time Data

time = pd.to_datetime(data['Time'], unit='ms')

This outputs a series of datetime64 data

0     2018-11-14 19:40:55.184
1     2018-11-14 19:50:55.324
2     2018-11-14 20:05:54.879
Name: Time, Length: 400, dtype: datetime64[ns]

So, there is where I am entirely lost. Matplotlib apparently doesn't plot datetime64 data.

plt.plot(time, pressure)

What matplotlib plots, with undecipherable time data on x-axis:

What matplotlib plots, with undecipherable time data on x-axis

So, how does one fix this? I mean, excel and matlab can easily plot this data. What on earth is going wrong here?

Final Edit:

I was able to isolate the issue to being an old version of matplotlib causing issues. In the environment I was having the issues with, I was using version 2.1.0 of matplotlib. The problem is no longer there if I run on version 3.0.0. This is purely an environment issue, and not code related.

  • see https://stackoverflow.com/questions/1574088/plotting-time-in-python-with-matplotlib – pangyuteng Nov 20 '18 at 00:06
  • You don't tell what `time` is here, but if you defined `time = data['Time2']`, the plot would look like [this](https://i.stack.imgur.com/PRCEU.png), which has a datetime in the format `%d %H:%M` on the axis. Please make sure to always provide a [mcve] when asking a question about undesired behaviour. – ImportanceOfBeingErnest Nov 20 '18 at 01:30
  • I edited my original question for clarity. The formatting of the date along the x-axis does not behave in that '%d %H: %M' format. Matplotlib appears to be converting it for me to some other data type. – Stephen Smith Nov 20 '18 at 02:06
  • As my comment above is trying to convey, matplotlib *does* show the datetimes in the required format. If it doesn't do that *for you*, you would want to provide a [mcve] and the picture produced by that example (not some other picture). Then make all information available that would allow to reproduce, i.e. versions of libraries in use, how you run the code etc. – ImportanceOfBeingErnest Nov 20 '18 at 02:14
  • @ImportanceOfBeingErnest It was an old version of matplotlib causing issues. By you being able to run code successfully, it made me question what was going on. I had been trying out IBM Watson, and they do not provide updated packages. I had assumed that the pacakges would work just fine since it was IBM hosting it. I ran the code locally through my Anaconda installation and had zero issues. I appreciate your help. – Stephen Smith Nov 20 '18 at 14:05
  • If you put the answer in the question, what's the purpose of the question? You may either delete the question or answer it. – ImportanceOfBeingErnest Nov 20 '18 at 15:59
  • Listen dude, this was my first question ever one the site. I spent a significant amount of time trying to figure this out on my own and decided to come here for **help**. You are attempting to squabble over technicalities now. Instead, you could have approached by saying "Great! Glad you got your problem fixed. In the future, if you find an answer, click on the box below to answer your question." Cool. If you're going to say something prickish, don't say it at all. – Stephen Smith Nov 20 '18 at 19:11

1 Answers1

0

I was able to isolate the issue to being an old version of matplotlib causing issues. In the environment I was having the issues with, I was using version 2.1.0 of matplotlib. The problem is no longer there if I run on version 3.0.0. This is purely an environment issue, and not code related.