I am currently trying to change my x-axis to a timeaxis. I’ve read a couple forum posts that discuss this, but I haven’t found a method that has worked while reading data from an external file. My current code is provided below, but all the different methods that I tried have been unfruitful, should I approach this in a different way? My data file “2014ex3.dat” consists of a set of values listed below, and I am trying to convert the date into a time axis, all while keeping values on the y-axis. I was thinking that maybe there is a way to convert the %lg itself into a time string? I am open to any methods and comments. I’ve attached a sample plot of what I would like it to turn into in ROOT. Thank you for your time.
I don’t know which forums you looked at, but your macro doesn’t do any attempt to create a time axis.
May be you should look at this page: root.cern.ch/how/how-create-axis-time-units
Thank you for the reply, I learned a lot from it. Changing the axis worked and I my x-axis is now in time, but now I am running into an error that reads my date column from my external file in epoch (20110101 -> 8/21/1970). Is there a way to convert the input via a command? I’ve tried the TDatime, but it only changes the axis. Thank you.
You need to translate the dates on x axis using TDatime. Therefore you should read the file using scanf or cin and convert the vector into dates using TDatime. I let you write the code reading the file. Here is a simple macro showing the result you will get (I just put the 2 dates you have in your at the beginning of the macro).