Skip to content

Commit

Permalink
Use barcharts instead
Browse files Browse the repository at this point in the history
  • Loading branch information
jake158 committed Mar 17, 2024
1 parent e1d017a commit f9473e2
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions pomodorodiscord/src/graphs.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,57 @@
import os
import sys
import matplotlib.pyplot as plt
from utils import load_data
from matplotlib.ticker import MaxNLocator

# Making sure you can run `python3 src/graphs.py`
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.dirname(current_dir)
sys.path.append(parent_dir)

from src.utils import load_data


def graph_pomodoro_sessions(data):
dates = list(data.get('sessions_by_date', {}).keys())
sessions = list(data.get('sessions_by_date', {}).values())
print(sessions)

plt.figure(figsize=(10, 6))
plt.plot(dates, sessions, marker='o')
plt.figure(figsize=(12, 8))
plt.bar(dates, sessions, color='blue', alpha=0.5, width=1)

plt.title('Pomodoro Sessions per Day')
plt.xlabel('Days')
plt.ylabel('Pomodoro Sessions')

# Format x-axis to display dates properly
ax = plt.gca()
ax.xaxis.set_major_locator(MaxNLocator(20))
plt.xticks(rotation=45)
plt.yticks(sessions)

plt.tight_layout()
plt.show()


def graph_hours_studied(data):
dates = list(data.get('seconds_by_date', {}).keys())
seconds = list(data.get('seconds_by_date', {}).values())
hours = [s / 3600 for s in seconds]

plt.figure(figsize=(10, 6))
plt.plot(dates, hours, marker='o', color='red')
plt.figure(figsize=(12, 8))
plt.bar(dates, hours, color='blue', alpha=0.5, width=1)

plt.title('Hours Studied per Day')
plt.xlabel('Days')
plt.ylabel('Hours Studied')

# Format x-axis to display dates properly
ax = plt.gca()
ax.xaxis.set_major_locator(MaxNLocator(20))
plt.xticks(rotation=45)

plt.tight_layout()
plt.show()


if __name__ == '__main__':
data = load_data()
graph_pomodoro_sessions(data)
Expand Down

0 comments on commit f9473e2

Please sign in to comment.