Plot data with UTC axis

453 views
Skip to first unread message

Ahmet Anil Dindar

unread,
May 15, 2016, 4:39:13 AM5/15/16
to Project Jupyter
Dear all,
I'm in an effort of transferring almost all of my calculations from Matlab to Jupyter as I admired your work. As a result of this effort, I'm having some issues to solve. The most recent one is to display the data on a graph where the x axis is in time format. Matlab introduced "datetime" variable type two year ago and it was perfect for me in my GPS data plots as shown below. The data for the horizontal axis is acquired from GPS observation data. 

Matlab Plot with UTC axix


I wonder whether anyone has a clue how to place datetime data in Jupyter plots?

Greetings from sunny Istanbul.

++Ahmet
------------------------------------------------------------------------------------------------------------------------------------------------------------- 
Ahmet Anil Dindar (Ph.D.)
Assistant Professor at  Istanbul Kultur University (IKU) & Department of Civil Engineering (IKU-CE)
Mobile: +90-532-548 63 93 || Office: +90-212-498 42 59 || Fax : +90-212-465 83 08
e-mail : adi...@iku.edu.tr || web:  http://www.iku.today/adindar/ || skype/gtalk : ahmetanildindar
Lat: 40.99138 N, Lon:28.83194 E (WGS84)
------------------------------------------------------------------------------------------------------------------------------------------------------------- 
"Growing old is inevitable; growing up is optional."

Matthias Bussonnier

unread,
May 16, 2016, 2:48:19 PM5/16/16
to jup...@googlegroups.com
Hello Ameth, 

We are happy to see that you are slowly being converted !
I suppose you are using Jupyter with Python (and the IPython kernel) as many users.
 Keep in mind that users are also using Jupyter with other languages so you might want to precise that next time. 

Then the nice thing is that many answer to your question can be answer by the broader Python community, and not only by the Jupyter one, 
as any answer that apply for Pure Python scripts apply to Jupyter notebook [I'll also assume you are using notebooks :-)]

Back to your question, 

When using Python the canonical way to plot is using matplotlib[1]. 
In particular if you look through the gallery[2], you will find this example[3] which seem to be close to what you are looking for. 

I was able to tweak it a bit[4] to get hours, minutes and seconds (and add the fill_between yellow area as well as legend). 
I did not add the smoothing, as I wasn't sure if it was part of your dataset or not. 

There are also a bunch of domain specific library that often provide convenience wrapper around matplotlib. 
If you are dealing with timeseries, I would strongly recommend looking at pandas[5], that seem to be done to do what you wish[6], 
and is generally **the** library you want to use for timeseries, and dataframes.  
Pandas give you matplotlib figures, so you can always tweak afterward, and recent matplotlib have also some hooks into pandas. 

Or if you prefer statistics, to give you an example of domain specific libraries: seaborn[7] is a really good choice. 

Hope that give you some hints of where to start, and if it make sens. 

Later you can have a look at plot.ly, bokeh, bqplot[8], that can add panning, zooming, and interactivity to your graphs. 

Feel free to ask if you have more questions, 

Thanks, 
-- 
Matthias





[8] google is your friend.

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/2e462cf8-4360-4700-9472-83a1cd96105d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ahmet Anil Dindar

unread,
May 17, 2016, 12:47:58 PM5/17/16
to jup...@googlegroups.com
Dear Matthias, I appreciate your recommendations. 

Bokeh is an incredible and very useful. I believe I'll concentrate more in Bokeh. 

Notebooks are fabulous in teaching and collaborating with the team. 

I'll do more in Jupyter Noteboks in near future. 

Regards.

satinath debnath

unread,
Jul 10, 2017, 10:54:36 PM7/10/17
to Project Jupyter
Hi Ahmet,
This is my first day in this group and not familiar with norms of this site. Anyway your graph is exactly matching with my plot. I am also trying to plot gnss receiver time with other parameter. But do not know how to plot UTC time on x-axis like you did. I am using python. Any help is highly appreciated.

Regards
Satinath

Paul Hobson

unread,
Jul 11, 2017, 12:52:14 AM7/11/17
to jup...@googlegroups.com
This less of a Jupyter questions and more of a matplotlib question. In either case, it'll be very difficult to give you concrete advice without seeing your data and and minimal working example of what you've tried.

In the meantime, checkout matplotlib's examples and gallery pages: http://matplotlib.org/examples/api/date_index_formatter.html
-p

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.

Ahmet Anil Dindar

unread,
Jul 11, 2017, 3:12:55 AM7/11/17
to Project Jupyter
Dear Paul, you are right. This is a matplotlib question rather than Python. 

Dear Satinath, my solution is below

Dear Satinath, 
The solution is given below. 

import matplotlib.dates as md

x = time_list
y = coordinates_list

plt.gca().xaxis.set_major_formatter(md.DateFormatter('%H:%M:%S')) # %m/%d/%Y

plt.plot(x,y)

I hope this works for you.

++Ahmet

------------------------------------------------------------------------------------
Ahmet Anil Dindar (Ph.D.)

Assistant Professor at  Gebze Technical University (GTU) & Department of Civil Engineering (GTU-CE)
Mobile: +90-532-548 63 93 || Office: +90-262-605 33 10 || Fax : +90-262-653 84 90
e-mail : 
adi...@gtu.edu.tr || web: https://github.com/ahmetanildindar || skype/gtalk : ahmetanildindar

Lat:  40.812662 N  Lon: 29.360680 E  || https://goo.gl/maps/4Y811nqafy32
------------------------------------------------------------------------------------
"Growing old is inevitable; growing up is optional."
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.

satinath debnath

unread,
Jul 11, 2017, 4:28:22 AM7/11/17
to jup...@googlegroups.com

Dear friends ,
Thanks for your response and solution of the problem .
I am new to this language .Will plot with your solution.

Thanks

Regards
Satinath

You received this message because you are subscribed to a topic in the Google Groups "Project Jupyter" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jupyter/w0B1BlFWtnM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jupyter+unsubscribe@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.

satinath debnath

unread,
Jul 11, 2017, 4:45:51 AM7/11/17
to jup...@googlegroups.com

Friends
I tried with following codes ..
data=numpy.genfromtxt('test.txt')
T=numpy.array(data[:,3])
Then your two lines
Followed by
Plt.plot(T,data[:,2])

It throws error

On Jul 11, 2017 12:42 PM, "Ahmet Anil Dindar" <ahmetan...@gmail.com> wrote:
You received this message because you are subscribed to a topic in the Google Groups "Project Jupyter" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jupyter/w0B1BlFWtnM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jupyter+unsubscribe@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages