From 6b00a950cea2247d3d4fdf32d25c672138558569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Mon, 30 Jan 2023 22:01:27 +0100 Subject: [PATCH] Show markers on smaller graphs --- CHANGELOG.md | 2 +- common/plots.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1af0c53..6caa765 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## Unrelease -* Add React * Make it possible to edit sessions (https://git.kucharczyk.xyz/lukas/timetracker/issues/46) +* Show markers on smaller graphs to make it clearer which dates the session belong to ## 1.0.0 / 2023-01-20 19:54+01:00 diff --git a/common/plots.py b/common/plots.py index 47e5f9c..6777443 100644 --- a/common/plots.py +++ b/common/plots.py @@ -64,7 +64,7 @@ def get_chart(data, title="", xlabel="", ylabel=""): plt.switch_backend("SVG") fig, ax = plt.subplots() fig.set_size_inches(10, 4) - ax.plot(x, y) + lines = ax.plot(x, y, "-o") first = x[0] last = x[-1] difference = last - first @@ -76,7 +76,11 @@ def get_chart(data, title="", xlabel="", ylabel=""): elif difference.days < 720: ax.xaxis.set_major_locator(mdates.MonthLocator()) ax.xaxis.set_minor_locator(mdates.WeekdayLocator()) + for line in lines: + line.set_marker("") else: + for line in lines: + line.set_marker("") ax.xaxis.set_major_locator(mdates.YearLocator()) ax.xaxis.set_minor_locator(mdates.MonthLocator())