Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyleoclim/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pyleoclim/utils/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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']:
Expand Down
14 changes: 8 additions & 6 deletions pyleoclim/utils/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):

'''
Expand All @@ -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'.
Expand All @@ -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
Expand Down Expand Up @@ -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)

'''
Expand All @@ -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']
Expand Down
Loading