Closed kzehnter closed 2 years ago
Hi! I think this is the flag you're looking for:
--time-format-output FORMAT, -F FORMAT
display time format (using standard datetime values)
You can view a list of datetime values here. For your example I think that would be %y-%m-%d %H:%M
.
The input date format will be guessed at runtime (for each row) which can be quite slow for large CSV files. You can use the --time-format-input
flag to specify the format so no guessing will be done, if you like.
Thank you first of all, I wasn't sure how to use these flags but now I got that down.
Still with a lot of data like an entry a minute the date and time values overlap and I can't read anything. If I get rid of the date I can see the time well but then the graph gets super weird when the next day starts because it only sorts by time.
I need something that is readable but also works over a couple of days of data.
Hm.. here's a few other options to play with:
--sort, -s sort xcol values
--resample FREQ, -r FREQ
resample values by FREQ and take the mean (default)
--xscale SCALE the x-axis scaling (default: auto)
--xrange RANGE the x-axis window (min:max) (default: auto)
xscale and xrange might not work well for time-series graphs though. If you have a sample CSV I can play around with it or possibly improve those options.
Okey, I've had time to play around with this again. I solved this by using:
graph --time-format-input "%y-%m-%d %H-%M" --time-format-output "%m:%d"
This way I don't clutter the x-axis but it still sorts data well by date.
Thank you for your help!
I would like to share my findings about --xrange and --xscale for time data
I want to have a label show up for every 10 minutes, so I use 600/86400
and get 0.0069444..... and use command line argument --xscale 0.0069444...
, I successfully make it put a label for every 10 minutes.
--xrange parameter is "number of days since 1970-1-1", yesterday (2023-05-11) is 19488th day, so I use --xrange 19488:19489
and the graph cuts perfectly from 2023-05-11 00:00 to 2023-05-11 23:59 without any padding.
19488.5:19489 makes it graph between 2023-05-11 12:00 and 2023-05-11 23:59
I hope this finding helps someone.
@axzxc1236 thanks for sharing that! I wonder if we could have the program do that conversion in a more user friendly way..
Warning:
In some cases datetime string with milliseconds str(datetime.datetime.now())
causes huge memory leak (it keeps ballooning).
Hey, what is the best way to have time and date as the x-axis? I can adjust my csv to a format which is well supported. I want the data to be sorted by Date first and then Time. YY-MM-DD HH:MM would be nice but I can't find good examples here.