From 062b12166e45a03c58c23bd268405c8b1d09ef0a Mon Sep 17 00:00:00 2001 From: Ching Date: Tue, 17 Mar 2026 06:38:21 +0000 Subject: [PATCH] =?UTF-8?q?fix(heatmap):=20=E4=BD=BF=E7=94=A8=E7=BB=9D?= =?UTF-8?q?=E5=AF=B9=E8=B7=AF=E5=BE=84=E5=B9=B6=E5=8E=BB=E6=8E=89=E7=83=AD?= =?UTF-8?q?=E5=8A=9B=E5=9B=BE=E6=9C=88=E4=BB=BD=E5=92=8C=E6=98=9F=E6=9C=9F?= =?UTF-8?q?=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 文件路径改为基于 __file__ 的绝对路径,确保 cron 运行时正确保存 - 去掉 weekday_label 和 month_label 避免文字挤在一起 Co-Authored-By: Claude Opus 4.6 --- heatmap.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/heatmap.py b/heatmap.py index b588336..2fa848e 100644 --- a/heatmap.py +++ b/heatmap.py @@ -18,7 +18,8 @@ client = Mastodon( api_base_url="https://nofan.xyz", ) -fn = "./heatmap.txt" +base_dir = os.path.dirname(os.path.abspath(__file__)) +fn = os.path.join(base_dir, "heatmap.txt") # read from file if exists date = [] data = [] @@ -79,9 +80,9 @@ with open(fn, "w") as f: f.close() cleaned_date, cleaned_data = july.utils.preprocess_inputs(date, data) -july.heatmap(cleaned_date, cleaned_data, cmap="BuGn") +july.heatmap(cleaned_date, cleaned_data, cmap="BuGn", month_grid=False, weekday_label=False, month_label=False) -img_path = "./heatmap.png" +img_path = os.path.join(base_dir, "heatmap.png") plt.savefig(img_path, bbox_inches="tight") # upload image to mastodon