When trying to plot some date-based values, I noticed that the default labels show too much precision. I was trying to plot some data points over a minutes to hours interval, and the default plot kept showing times using a micro-second precision. Given that the major ticks were minutes apart, this seems overkill to me (and the extra digits quickly clutter the display, making the labels overlap).
Diving into the code, it seems the default "scaled" member of the
AutoDateFormatter, which determines what formats to use when, can be
improved. Currently, it:
Uses microsecond precision when the ticks are minutes or less apart.
Uses second precision when the ticks are hours apart
Uses day-precision, month or year precision when the ticks are days
or more apart (these are fine, so I lumped them together).
I think it should be like this:
Use microsecond precision when the ticks less than a second apart
Use second precision when the ticks are seconds apart
Use minute precision when the ticks are minutes or hours apart
Use day-precision, month or year precision when the ticks are days
or more apart (unchanged).
Note that there is no point in displaying only the hour when the ticks
are hours apart, since then it won't be immediately clear that a time is
being displayed. Adding the (technically superfluous) :00 for the
minutes should prevent this, which is why the minute precision should
also be used when the ticks are hours apart.
The above would be implemented by the following change (documentation
not updated yet):
This might be perfect for the upcoming v2.0 style-change release, but I
wouldn't be against it being treated as a bugfix and put into 1.5 (to be
released soon). Could you put together a Pull Request with this change?
This way, we can see exactly how this looks as it would (hopefully) break
some unit tests.
When trying to plot some date-based values, I noticed that the default
labels show too much precision. I was trying to plot some data points over
a minutes to hours interval, and the default plot kept showing times using
a micro-second precision. Given that the major ticks were minutes apart,
this seems overkill to me (and the extra digits quickly clutter the
display, making the labels overlap).
Diving into the code, it seems the default "scaled" member of the
AutoDateFormatter, which determines what formats to use when, can be
improved. Currently, it:
Uses microsecond precision when the ticks are minutes or less apart.
Uses second precision when the ticks are hours apart
Uses day-precision, month or year precision when the ticks are days
or more apart (these are fine, so I lumped them together).
I think it should be like this:
Use microsecond precision when the ticks less than a second apart
Use second precision when the ticks are seconds apart
Use minute precision when the ticks are minutes or hours apart
Use day-precision, month or year precision when the ticks are days
or more apart (unchanged).
Note that there is no point in displaying only the hour when the ticks
are hours apart, since then it won't be immediately clear that a time is
being displayed. Adding the (technically superfluous) :00 for the
minutes should prevent this, which is why the minute precision should
also be used when the ticks are hours apart.
The above would be implemented by the following change (documentation
not updated yet):
Quite some time ago I was making a plot with dates, and tried to get the axis to format milliseconds.
I could not get that working, there were some comments around that it was not possible, so I stopped trying, and made sure that it was only second resolution which became very coarse, but displaying the microseconds just added too many digits for readability.
Would it be possible to add milliseconds to the formatter, or at least the choise of digits in the formatter.
It's kind of a large step to go from seconds to microseconds,
I think it would be appreciated if milliseconds appeared before microseconds.
Activity
WeatherGod commented on Jul 28, 2015
This might be perfect for the upcoming v2.0 style-change release, but I
wouldn't be against it being treated as a bugfix and put into 1.5 (to be
released soon). Could you put together a Pull Request with this change?
This way, we can see exactly how this looks as it would (hopefully) break
some unit tests.
On Tue, Jul 28, 2015 at 10:40 AM, Matthijs Kooijman <
notifications@github.com> wrote:
Reduce AutoDateFormatter precision when possible
matthijskooijman commented on Jul 28, 2015
Thanks for your reply, I created a PR just now.
DFLT: change formats for AutoDateFormatter
DFLT: change formats for AutoDateFormatter
DFLT: change formats for AutoDateFormatter
DFLT: change formats for AutoDateFormatter
DFLT: change formats for AutoDateFormatter
DFLT: change formats for AutoDateFormatter
DFLT: change formats for AutoDateFormatter
DFLT: change formats for AutoDateFormatter
ahed87 commented on Nov 27, 2015
Hi,
a bit of hi-jack, but...
Quite some time ago I was making a plot with dates, and tried to get the axis to format milliseconds.
I could not get that working, there were some comments around that it was not possible, so I stopped trying, and made sure that it was only second resolution which became very coarse, but displaying the microseconds just added too many digits for readability.
Would it be possible to add milliseconds to the formatter, or at least the choise of digits in the formatter.
It's kind of a large step to go from seconds to microseconds,
I think it would be appreciated if milliseconds appeared before microseconds.
DFLT: change formats for AutoDateFormatter
DFLT: change formats for AutoDateFormatter
DFLT: change formats for AutoDateFormatter
DFLT: change formats for AutoDateFormatter
DFLT: change formats for AutoDateFormatter
DFLT: change formats for AutoDateFormatter
DFLT: change formats for AutoDateFormatter
DFLT: change formats for AutoDateFormatter