| 1135 | _check_plot_works(df.plot, ax=ax) |
| 1136 | |
| 1137 | def test_time(self): |
| 1138 | t = datetime(1, 1, 1, 3, 30, 0) |
| 1139 | deltas = np.random.default_rng(2).integers(1, 20, 3).cumsum() |
| 1140 | ts = np.array([(t + timedelta(minutes=int(x))).time() for x in deltas]) |
| 1141 | df = DataFrame( |
| 1142 | { |
| 1143 | "a": np.random.default_rng(2).standard_normal(len(ts)), |
| 1144 | "b": np.random.default_rng(2).standard_normal(len(ts)), |
| 1145 | }, |
| 1146 | index=ts, |
| 1147 | ) |
| 1148 | _, ax = mpl.pyplot.subplots() |
| 1149 | df.plot(ax=ax) |
| 1150 | |
| 1151 | # verify tick labels |
| 1152 | ticks = ax.get_xticks() |
| 1153 | labels = ax.get_xticklabels() |
| 1154 | for _tick, _label in zip(ticks, labels, strict=True): |
| 1155 | m, s = divmod(int(_tick), 60) |
| 1156 | h, m = divmod(m, 60) |
| 1157 | rs = _label.get_text() |
| 1158 | if len(rs) > 0: |
| 1159 | if s != 0: |
| 1160 | xp = time(h, m, s).strftime("%H:%M:%S") |
| 1161 | else: |
| 1162 | xp = time(h, m, s).strftime("%H:%M") |
| 1163 | assert xp == rs |
| 1164 | |
| 1165 | def test_time_change_xlim(self): |
| 1166 | t = datetime(1, 1, 1, 3, 30, 0) |