Skip to content

Commit 2171b46

Browse files
committed
Improve axis formatting and bump version to 8.7.0
Refactored axis title and tick font handling in annotate_peak.py for better consistency and appearance. Added uirevision to layout for stable UI updates. Removed unused colour_dict argument from main block. Updated setup.py to version 8.7.0 and adjusted download_url accordingly.
1 parent c6fe22c commit 2171b46

2 files changed

Lines changed: 37 additions & 14 deletions

File tree

metbit/annotate_peak.py

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -335,15 +335,31 @@ def pick_color(trace_key: str, group_key: str | None = None):
335335
a2['font']['size'] = font_size
336336
anns.append(a2)
337337

338-
fig.update_xaxes(autorange="reversed",
339-
title="<b>δ <sup>1</sup>H<b>", title_font=dict(size=font_size*1.5),
340-
tickfont=dict(size=max(font_size-2, 8)),
341-
showgrid=True, gridcolor="rgba(0,0,0,0.05)", zeroline=False)
342-
fig.update_yaxes(title="<b>Intensity</b>", title_font=dict(size=font_size),
343-
tickfont=dict(size=max(font_size-2, 8)),
344-
showgrid=True, gridcolor="rgba(0,0,0,0.05)", zeroline=False)
338+
fig.update_xaxes(
339+
autorange="reversed",
340+
title=dict(
341+
text="<b>δ <sup>1</sup>H</b>",
342+
font=dict(size=int(font_size*1.5))
343+
),
344+
tickfont=dict(size=max(font_size-2, 8)),
345+
showgrid=True,
346+
gridcolor="rgba(0,0,0,0.05)",
347+
zeroline=False
348+
)
349+
350+
fig.update_yaxes(
351+
title=dict(
352+
text="<b>Intensity</b>",
353+
font=dict(size=int(font_size*1.5))
354+
),
355+
tickfont=dict(size=max(font_size-2, 8)),
356+
showgrid=True,
357+
gridcolor="rgba(0,0,0,0.05)",
358+
zeroline=False
359+
)
345360

346361
fig.update_layout(
362+
uirevision="constant",
347363
template="plotly_white",
348364
annotations=anns,
349365
autosize=True,
@@ -371,15 +387,22 @@ def pick_color(trace_key: str, group_key: str | None = None):
371387
showline=True, # enable axis line
372388
linecolor="black", # axis line color
373389
linewidth=2, # axis line width
374-
mirror=False # show line on both bottom & top
390+
mirror=False, # show line only on bottom
391+
title=dict(
392+
text="<b>δ <sup>1</sup>H</b>",
393+
font=dict(size=int(font_size*1.5), color="black")
394+
),
395+
tickfont=dict(size=max(font_size-2, 9), color="black")
375396
),
376397
yaxis=dict(
377398
showline=True,
378399
linecolor="black",
379400
linewidth=2,
380-
mirror=False,
381-
title="<b>Intensity</b>",
382-
titlefont=dict(size=font_size*1.5, color="black"),
401+
mirror=False, # show line only on left
402+
title=dict(
403+
text="<b>Intensity</b>",
404+
font=dict(size=int(font_size*1.5), color="black")
405+
),
383406
tickfont=dict(size=max(font_size-2, 9), color="black"),
384407
exponentformat="power", # use 10^n style
385408
showexponent="all"
@@ -578,5 +601,5 @@ def run(self, debug=True, port=8050):
578601
df = pd.read_csv('https://raw.githubusercontent.com/aeiwz/example_data/main/dataset/Example_NMR_data.csv')
579602
spectra = df.iloc[:, 1:]
580603
label = df['Group']
581-
annotator = annotate_peak(meta=label, spectra=spectra, label=label, colour_dict={"A":"green"})
604+
annotator = annotate_peak(meta=label, spectra=spectra, label=label)
582605
annotator.run(debug=True, port=8052)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
setup(
1313
name = 'metbit',
1414
packages = ['metbit'],
15-
version = '8.6.2',
15+
version = '8.7.0',
1616
license='MIT',
1717
description = 'Metabolomics data analysis and visualization tools.',
1818
author = 'aeiwz',
1919
author_email = 'theerayut_aeiw_123@hotmail.com',
2020
url = 'https://github.com/aeiwz/metbit.git',
21-
download_url = 'https://github.com/aeiwz/metbit/archive/refs/tags/V8.6.2.tar.gz',
21+
download_url = 'https://github.com/aeiwz/metbit/archive/refs/tags/V8.7.0.tar.gz',
2222
keywords = ['Omics', 'Multivariate analysis', 'Visualization', 'Data Analysis', 'Metabolomics', 'Chemometrics'],
2323
install_requires=[
2424
'scikit-learn',

0 commit comments

Comments
 (0)