Tuesday, October 19, 2021

Plotting dates

Suppose you're plotting some attribute against time and so, on the horizontal axis you have years or dates. You might produce a graph such as the following which is of a currency exchange rate:

However one problem is that a year such as 2021 is an interval of time, indeed it is a full year, but on the graph it is presented as a point in time. When an interval of time is presented as a point in time, it reduces the clarity of the graph.
We could improve matters by displaying years as intervals. For example look at the following graph showing 5 years of data:

Sometimes we show graphs of data and the total interval of time is shorter. The graph below shows 12 months worth of data:

Again we have a familiar problem. A month is an interval in time, but on the graph above it is presented as a point in time.
Similarly we can be a bit more diciplined about showing an interval of time as an interval, rather than a point. For example we could have the following graph:

The aim is to be both precise and to be clear.
We often have a similar issue when we have just a few days of data. In that case we need to remember that a date represents a day which is 24 hours long, it is not a point in time!
There are a few caveats:
If we're showing many years of data, then relatively speaking, one year is short, so it is approximately a point. Similarly if we have hundreds of days of data, then one day is almost just a point.
There are also cases when the data is aggregated over a period. We might show monthly rain-fall in that case it may make more sense to display the month as a point, since it represents one data point and not a segment of the graph.
On the other hand if we are showing data within one day, then a time such as 10am is indeed just a point, it is not an interval. 10am does not last for one hour, it is just a point in time. In that respect it is unlike a date, which represents a full day. A date is not a point in time, it is an interval of 24 hours.
But overall, the moral of the story is: if you're using a time interval (year, month, day) as a label on a graph, then it should be diplayed as a time interval and not a point in time.