Skip to content

Commit 27b1a36

Browse files
committed
ENH: add musecond scale to AutoDateFormatter
The lack of this scale is pointed out in matplotlib#6365 and was the big difference between pandas AutoDateFormatter and the stock upstream version.
1 parent 6d161d6 commit 27b1a36

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

doc/users/whats_new/rcparams.rst

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
Configuration (rcParams)
22
------------------------
33

4-
+----------------------------+--------------------------------------------------+
5-
| Parameter | Description |
6-
+============================+==================================================+
7-
|`date.autoformatter.year` | foramt string for 'year' scale dates |
8-
+----------------------------+--------------------------------------------------+
9-
|`date.autoformatter.month` | format string for 'month' scale dates |
10-
+----------------------------+--------------------------------------------------+
11-
|`date.autoformatter.day` | format string for 'day' scale dates |
12-
+----------------------------+--------------------------------------------------+
13-
|`date.autoformatter.hour` | format string for 'hour' scale times |
14-
+----------------------------+--------------------------------------------------+
15-
|`date.autoformatter.minute` | format string for 'minute' scale times |
16-
+----------------------------+--------------------------------------------------+
17-
|`date.autoformatter.second` | format string for 'second' scale times |
18-
+----------------------------+--------------------------------------------------+
19-
|`scatter.marker` | default marker for scatter plot |
20-
+----------------------------+--------------------------------------------------+
21-
|`svg.hashsalt` | see note |
22-
+----------------------------+--------------------------------------------------+
4+
+---------------------------------+--------------------------------------------------+
5+
| Parameter | Description |
6+
+=================================+==================================================+
7+
|`date.autoformatter.year` | foramt string for 'year' scale dates |
8+
+---------------------------------+--------------------------------------------------+
9+
|`date.autoformatter.month` | format string for 'month' scale dates |
10+
+---------------------------------+--------------------------------------------------+
11+
|`date.autoformatter.day` | format string for 'day' scale dates |
12+
+---------------------------------+--------------------------------------------------+
13+
|`date.autoformatter.hour` | format string for 'hour' scale times |
14+
+---------------------------------+--------------------------------------------------+
15+
|`date.autoformatter.minute` | format string for 'minute' scale times |
16+
+---------------------------------+--------------------------------------------------+
17+
|`date.autoformatter.second` | format string for 'second' scale times |
18+
+---------------------------------+--------------------------------------------------+
19+
|`date.autoformatter.microsecond` | format string for 'microsecond' scale times |
20+
+---------------------------------+--------------------------------------------------+
21+
|`scatter.marker` | default marker for scatter plot |
22+
+---------------------------------+--------------------------------------------------+
23+
|`svg.hashsalt` | see note |
24+
+---------------------------------+--------------------------------------------------+
2325

2426
Added ``svg.hashsalt`` key to rcParams
2527
```````````````````````````````````````

lib/matplotlib/dates.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,9 @@ class AutoDateFormatter(ticker.Formatter):
634634
1.0: rcParams['date.autoformat.day'],
635635
1. / HOURS_PER_DAY: rcParams['date.autoformat.hour'],
636636
1. / (MINUTES_PER_DAY): rcParams['date.autoformat.minute'],
637-
1. / (SEC_PER_DAY): rcParams['date.autoformat.second']}
637+
1. / (SEC_PER_DAY): rcParams['date.autoformat.second'],
638+
1. / (MUSECONDS_PER_DAY): rcParams['date.autoformat.microsecond'],
639+
}
638640
639641
640642
The algorithm picks the key in the dictionary that is >= the
@@ -693,7 +695,9 @@ def __init__(self, locator, tz=None, defaultfmt='%Y-%m-%d'):
693695
1. / (MINUTES_PER_DAY):
694696
rcParams['date.autoformatter.minute'],
695697
1. / (SEC_PER_DAY):
696-
rcParams['date.autoformatter.second']}
698+
rcParams['date.autoformatter.second'],
699+
1. / (MUSECONDS_PER_DAY):
700+
rcParams['date.autoformatter.microsecond']}
697701

698702
def __call__(self, x, pos=None):
699703
locator_unit_scale = float(self._locator._get_unit())

lib/matplotlib/rcsetup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,8 @@ def validate_hist_bins(s):
10971097
'date.autoformatter.day': ['%Y-%m-%d', six.text_type],
10981098
'date.autoformatter.hour': ['%H:%M', six.text_type],
10991099
'date.autoformatter.minute': ['%H:%M:%S', six.text_type],
1100-
'date.autoformatter.second': ['%H:%M:%S.%f', six.text_type],
1100+
'date.autoformatter.second': ['%H:%M:%S', six.text_type],
1101+
'date.autoformatter.microsecond': ['%H:%M:%S.%f', six.text_type],
11011102

11021103
#legend properties
11031104
'legend.fancybox': [True, validate_bool],

matplotlibrc.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ backend : $TEMPLATE_BACKEND
355355
# date.autoformatter.day : %Y-%m-%d
356356
# date.autoformatter.hour : %H:%M
357357
# date.autoformatter.minute : %H:%M:%S
358-
# date.autoformatter.second : %H:%M:%S.%f
358+
# date.autoformatter.second : %H:%M:%S
359+
# date.autoformatter.microsecond : %H:%M:%S.%f
359360

360361
### TICKS
361362
# see http://matplotlib.org/api/axis_api.html#matplotlib.axis.Tick

0 commit comments

Comments
 (0)