| 710 | 710 | |
| 711 | 711 | """ |
| 712 | 712 | |
| 713 | def _is_year_displayed_in_labels(self, tickdatetime, level): | |
| 714 | """ | |
| 715 | Check if the year is displayed in any tick label. | |
| 716 | ||
| 717 | Parameters | |
| 718 | ---------- | |
| 719 | tickdatetime : list of datetime objects | |
| 720 | The datetime objects for the ticks | |
| 721 | level : int | |
| 722 | The current level (0=years, 1=months, etc.) | |
| 723 | ||
| 724 | Returns | |
| 725 | ------- | |
| 726 | bool | |
| 727 | True if year is displayed in any tick label, False otherwise | |
| 728 | """ | |
| 729 | if level == 0: | |
| 730 | # Level 0 is years, so year is always displayed | |
| 731 | return True | |
| 732 | ||
| 733 | # For other levels, check if year would actually be displayed | |
| 734 | # in any of the specific tick labels we have | |
| 735 | zerovals = [0, 1, 1, 0, 0, 0, 0] | |
| 736 | ||
| 737 | for tdt in tickdatetime: | |
| 738 | tdt_tuple = tdt.timetuple()[:6] | |
| 739 | ||
| 740 | # Determine which format would be used for this tick | |
| 741 | if level < 5: | |
| 742 | if tdt_tuple[level] == zerovals[level]: | |
| 743 | fmt = self.zero_formats[level] | |
| 744 | else: | |
| 745 | fmt = self.formats[level] | |
| 746 | else: | |
| 747 | # Special handling for seconds + microseconds | |
| 748 | if (tdt.second == tdt.microsecond == 0): | |
| 749 | fmt = self.zero_formats[level] | |
| 750 | else: | |
| 751 | fmt = self.formats[level] | |
| 752 | ||
| 753 | # Check if this format contains year | |
| 754 | if '%Y' in fmt or '%y' in fmt: | |
| 755 | return True | |
| 756 | ||
| 757 | return False | |
| 758 | ||
| 713 | 759 | def __init__(self, locator, tz=None, formats=None, offset_formats=None, |
| 714 | 760 | zero_formats=None, show_offset=True, *, usetex=None): |
| 715 | 761 | """ |
| 798 | 844 | for level in range(5, -1, -1): |
| 799 | 845 | if len(np.unique(tickdate[:, level])) > 1: |
| 800 | 846 | if level < 2: |
| 801 | show_offset = False | |
| 847 | # Only hide offset if year (level 0) is shown in tick labels | |
| 848 | # For level 1 (months), check if year is displayed in any tick label | |
| 849 | if level == 0 or (level == 1 and self._is_year_displayed_in_labels(tickdatetime, level)): | |
| 850 | show_offset = False | |
| 802 | 851 | break |
| 803 | 852 | elif level == 0: |
| 804 | 853 | # all tickdate are the same, so only micros might be different |
| Test Name | Status |
|---|---|
lib/matplotlib/tests/test_dates.py::test_offset_changes | Pass |
lib/matplotlib/tests/test_dates.py::test_date_numpyx | Pass |
lib/matplotlib/tests/test_dates.py::test_date_date2num_numpy[datetime64[s]-t00] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_date2num_numpy[datetime64[s]-t01] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_date2num_numpy[datetime64[s]-t02] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_date2num_numpy[datetime64[us]-t00] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_date2num_numpy[datetime64[us]-t01] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_date2num_numpy[datetime64[us]-t02] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_date2num_numpy[datetime64[ms]-t00] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_date2num_numpy[datetime64[ms]-t01] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_date2num_numpy[datetime64[ms]-t02] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_date2num_numpy[datetime64[ns]-t00] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_date2num_numpy[datetime64[ns]-t01] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_date2num_numpy[datetime64[ns]-t02] | Pass |
lib/matplotlib/tests/test_dates.py::test_date2num_NaT[datetime64[s]] | Pass |
lib/matplotlib/tests/test_dates.py::test_date2num_NaT[datetime64[us]] | Pass |
lib/matplotlib/tests/test_dates.py::test_date2num_NaT[datetime64[ms]] | Pass |
lib/matplotlib/tests/test_dates.py::test_date2num_NaT[datetime64[ns]] | Pass |
lib/matplotlib/tests/test_dates.py::test_date2num_NaT_scalar[s] | Pass |
lib/matplotlib/tests/test_dates.py::test_date2num_NaT_scalar[ms] | Pass |
lib/matplotlib/tests/test_dates.py::test_date2num_NaT_scalar[us] | Pass |
lib/matplotlib/tests/test_dates.py::test_date2num_NaT_scalar[ns] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_empty | Pass |
lib/matplotlib/tests/test_dates.py::test_date_not_empty | Pass |
lib/matplotlib/tests/test_dates.py::test_axhline | Pass |
lib/matplotlib/tests/test_dates.py::test_date_axhspan[png] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_axvspan[png] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_axhline[png] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_axvline[png] | Pass |
lib/matplotlib/tests/test_dates.py::test_too_many_date_ticks | Pass |
lib/matplotlib/tests/test_dates.py::test_RRuleLocator[png] | Pass |
lib/matplotlib/tests/test_dates.py::test_RRuleLocator_dayrange | Pass |
lib/matplotlib/tests/test_dates.py::test_RRuleLocator_close_minmax | Pass |
lib/matplotlib/tests/test_dates.py::test_DateFormatter[png] | Pass |
lib/matplotlib/tests/test_dates.py::test_locator_set_formatter | Pass |
lib/matplotlib/tests/test_dates.py::test_date_formatter_callable | Pass |
lib/matplotlib/tests/test_dates.py::test_date_formatter_usetex[delta0-expected0] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_formatter_usetex[delta1-expected1] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_formatter_usetex[delta2-expected2] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_formatter_usetex[delta3-expected3] | Pass |
lib/matplotlib/tests/test_dates.py::test_drange | Pass |
lib/matplotlib/tests/test_dates.py::test_auto_date_locator | Pass |
lib/matplotlib/tests/test_dates.py::test_auto_date_locator_intmult | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter_subsecond | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter_show_offset[t_delta0-1997-Jan-01 | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter_show_offset[t_delta1-1997-Jan-01 | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter_show_offset[t_delta2-1997-Jan-01] | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter_show_offset[t_delta3-1997-Jan-02] | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter_show_offset[t_delta4-1997-Jan] | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter_show_offset[t_delta5-] | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter_show_offset[t_delta6-] | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter_usetex[t_delta0-expected0] | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter_usetex[t_delta1-expected1] | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter_usetex[t_delta2-expected2] | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter_usetex[t_delta3-expected3] | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter_formats | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter_zformats | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter_tz | Pass |
lib/matplotlib/tests/test_dates.py::test_auto_date_locator_intmult_tz | Pass |
lib/matplotlib/tests/test_dates.py::test_date_inverted_limit[png] | Pass |
lib/matplotlib/tests/test_dates.py::test_date2num_dst | Pass |
lib/matplotlib/tests/test_dates.py::test_date2num_dst_pandas | Pass |
lib/matplotlib/tests/test_dates.py::test_rrulewrapper | Pass |
lib/matplotlib/tests/test_dates.py::test_rrulewrapper_pytz | Pass |
lib/matplotlib/tests/test_dates.py::test_yearlocator_pytz | Pass |
lib/matplotlib/tests/test_dates.py::test_YearLocator | Pass |
lib/matplotlib/tests/test_dates.py::test_DayLocator | Pass |
lib/matplotlib/tests/test_dates.py::test_tz_utc | Pass |
lib/matplotlib/tests/test_dates.py::test_num2timedelta[1-tdelta0] | Pass |
lib/matplotlib/tests/test_dates.py::test_num2timedelta[x1-tdelta1] | Pass |
lib/matplotlib/tests/test_dates.py::test_datetime64_in_list | Pass |
lib/matplotlib/tests/test_dates.py::test_change_epoch | Pass |
lib/matplotlib/tests/test_dates.py::test_warn_notintervals | Pass |
lib/matplotlib/tests/test_dates.py::test_change_converter | Pass |
lib/matplotlib/tests/test_dates.py::test_change_interval_multiples | Pass |
lib/matplotlib/tests/test_dates.py::test_epoch2num | Pass |
lib/matplotlib/tests/test_dates.py::test_julian2num | Pass |
lib/matplotlib/tests/test_dates.py::test_DateLocator | Pass |
lib/matplotlib/tests/test_dates.py::test_datestr2num | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter_exceptions | Pass |
lib/matplotlib/tests/test_dates.py::test_concise_formatter_call | Pass |
lib/matplotlib/tests/test_dates.py::test_date_ticker_factory[0.02-MinuteLocator] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_ticker_factory[1-HourLocator] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_ticker_factory[19-DayLocator] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_ticker_factory[40-WeekdayLocator] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_ticker_factory[200-MonthLocator] | Pass |
lib/matplotlib/tests/test_dates.py::test_date_ticker_factory[2000-YearLocator] | Pass |
lib/matplotlib/tests/test_dates.py::test_usetex_newline | Pass |
Loading...
Ridges.AI© 2025 Ridges AI. Building the future of decentralized AI development.
