diff --git a/pyleoclim/core/series.py b/pyleoclim/core/series.py index a7da9b64..3f10144a 100644 --- a/pyleoclim/core/series.py +++ b/pyleoclim/core/series.py @@ -1129,7 +1129,7 @@ def plot(self, figsize=[10, 4], fig, ax = ts_18.plot(figsize=(10, 4),linewidth=0.5) ax.invert_yaxis() # d18O is traditionally inverted - fig, ax = pyleo.add_GTS(fig, ax, ranks=['Period', 'Epoch'], location='above') + fig, ax = pyleo.add_GTS(fig, ax, time_unit=ts_18.time_unit, ranks=['Period', 'Epoch'], location='above') ''' # generate default axis labels diff --git a/pyleoclim/utils/datasets.py b/pyleoclim/utils/datasets.py index 94d275a9..a52b847d 100644 --- a/pyleoclim/utils/datasets.py +++ b/pyleoclim/utils/datasets.py @@ -233,7 +233,7 @@ def _localname(term): def load_ics_chart_to_df(ttl_path_or_url="https://raw.githubusercontent.com/i-c-stratigraphy/chart/refs/heads/main/chart.ttl", - time_units='Ma', lang='en') -> pd.DataFrame: + time_unit='Ma', lang='en') -> pd.DataFrame: def _first_lang(iterable, lang=None): for lit in iterable: @@ -366,7 +366,7 @@ def boundary_ma(node_pred): df["Rank"] = pd.Categorical(df["Rank"], categories=type_order + sorted(set(df["Rank"]) - set(type_order)), ordered=True) df = df.sort_values(["Rank", "UpperBoundary"], na_position="last").reset_index(drop=True) - time_name, time_unit = disambiguate_time_metadata(time_units) + time_name, time_unit = disambiguate_time_metadata(time_unit) print(f"Time name: {time_name}") print(f"Time unit: {time_unit}") if time_unit not in ['Ma']:#['Ma', 'Mya', 'My']: diff --git a/pyleoclim/utils/plotting.py b/pyleoclim/utils/plotting.py index bd830cf0..8fb7bfdf 100644 --- a/pyleoclim/utils/plotting.py +++ b/pyleoclim/utils/plotting.py @@ -1518,9 +1518,9 @@ def text_loc(fig, ax, rect, label_text, width, yloc): text.remove() return loc -def add_GTS(fig, ax, time_units, GTS_df=None, ranks=None, location='above', label_pref='full', - allow_abbreviations=True, ax_name='gts', v_offset=0, height=.05, text_color=None, fontsize=None, edgecolor='k', - edgewidth=0, alpha=1,zorder=10,reverse_rank_order=True, lang='en', +def add_GTS(fig, ax, time_unit, GTS_df=None, ranks=None, location='above', label_pref='full', + allow_abbreviations=True, lang='en', ax_name='gts', v_offset=0, height=.05, text_color=None, fontsize=None, edgecolor='k', + edgewidth=0, alpha=1,zorder=10,reverse_rank_order=True, gts_url = "https://raw.githubusercontent.com/i-c-stratigraphy/chart/refs/heads/main/chart.ttl"): ''' @@ -1531,7 +1531,7 @@ def add_GTS(fig, ax, time_units, GTS_df=None, ranks=None, location='above', labe The figure object where the GTS will be added. ax : dict The axis where the GTS will be plotted. - time_units : str + time_unit : str Time units of the GTS data. Supported: 'Ma' (default), 'ka', 'Ga'. GTS_df : pd.DataFrame, optional DataFrame containing the GTS data with columns for 'Rank', 'Name', 'Abbrev', 'Color', 'UpperBoundary', 'LowerBoundary'. @@ -1544,6 +1544,8 @@ def add_GTS(fig, ax, time_units, GTS_df=None, ranks=None, location='above', labe Preference for labels: 'full' (default) for full names, 'abbrev' for abbreviations, 'none' for no labels (only colors). allow_abbreviations : bool, optional If True, allows abbreviations for labels that don't fit. Default is True. + lang : str, optional + Language for GTS labels. Default is 'en'. ax_name : str, optional Name of the axis to create for the GTS. Default is 'gts'. v_offset : float, optional @@ -1587,7 +1589,7 @@ def add_GTS(fig, ax, time_units, GTS_df=None, ranks=None, location='above', labe fig, ax = ms.stackplot(figsize=(10, 5),linewidth=0.5, fill_between_alpha=0) ax[0].invert_yaxis() # d18O is traditionally inverted - fig, ax = pyleo.utils.plotting.add_GTS(fig, ax, time_units='Ma', location='above', label_pref='full', + fig, ax = pyleo.utils.plotting.add_GTS(fig, ax, 'Ma', location='above', label_pref='full', allow_abbreviations=True, ax_name='gts', v_offset=0, height=.05) ''' @@ -1608,7 +1610,7 @@ def add_GTS(fig, ax, time_units, GTS_df=None, ranks=None, location='above', labe assert all(duration >= 0), "GTS_df 'LowerBoundary' must be greater than (further back in time) or equal to 'UpperBoundary (more modern)'" if GTS_df is None: - GTS_df = datasets.load_ics_chart_to_df(gts_url, time_units=time_units, lang=lang) + GTS_df = datasets.load_ics_chart_to_df(gts_url, time_unit=time_unit, lang=lang) if ranks is None: ranks = ['Period', 'Epoch', 'Stage']