New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timeseries plots #22
Comments
That's definitely a good suggestion! Shouldn't be too difficult to handle Datetime objects properly (scaling using epoch time and labeling with human-readable text). I'll try to have a look at it in the next week or so. Also: wonderful to see tplot being used for cool stuff, that figure looks great! |
Handling datetime objects is more difficult than I thought. I figured I could just use epoch timestamps to plot everything as numbers and show the datetime as a string for the axis tick labels, but that beaks the assumption that tick labels and their values are the same - something that is pretty fundamental to how tplot is set up. There's also the issue of the interval between ticks. tplot creates ticks at round(ish) intervals like 1, 2, 5, 10, 20, 50, 100, etc. This doesn't work for a lot of situations with datetimes: tplot might decide on a 100 000 second tick interval, which is a nice round number in seconds (and epoch timestamps are in seconds), but measured in days that's roughly 1.1574074 - yuck! Depending on what timescale you're plotting, tick intervals end up looking arbitrary. And then there's units of time that have a variable length, such as months or years (leap days). Time is complicated. Maybe there are existing open source implementations for getting an appropriate time interval given a set of dates and times, and solutions for any other peculiarities that come up. But unless there's significant interest from a lot of people, I don't think it's worth trying to support datetime objects. It could potentially add a lot of complexity, and I'd like to keep tplot simple. Your current solution of converting datetimes to a manually chosen time interval (e.g. number of days) seems like the best approach. If you really need to handle datetime objects with all the complexity they bring, there are enough feature-rich plotting libraries out there that can do pretty much whatever you want, including plotting date intervals nine ways to Sunday. Sorry to get your hopes up! |
I am instead using the largest differentiating unit as this grants me better human-readability, at least in some circumstances, without having to resort to relative values. This function converts datetimes to a dynamic range of numbers. |
I've been playing with
tplot
for a few days now building a command-line tool to show some usage data, basically I've created a CLI connectingpandas.read_csv
totplot
. This has turned out really well and the plots look great in the terminal.Any thoughts on the best way to handle timeseries/datetime on the x-axis? One approach might be for the user to just cast the timestamps to Unix epoch times, but that's not very human readable on the axis labels. Do you have any sense of how much of a challenge it would be to construct a label formatter on the x-axis to show dates and times nicely (like months+days, or hours+minutes)?
Just sharing ideas, thanks.
The text was updated successfully, but these errors were encountered: