import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
studyminutes=[]
date=[]
studyminutesdf = pd.DataFrame({"Date": date, "Studyminutes":studyminutes})
# DataFrame化しておく。
from random import randint
for i in range(1, 32): #新テストデータ
studyminutes.append(randint(20, 80))
date.append("5/"+str(i))
検討中
fig, ax = plt.subplots()
ax.bar(studyminutesdf['Date'], studyminutesdf['Studyminutes'])
ax.set_title("Study minutes in a month")
ax.set_xlabel("Date")
ax.set_ylabel("Study minutes")
ax.set_xticklabels(studyminutesdf['Date'], rotation = 90)
studyminutesdf_week = studyminutesdf.iloc[-7:, :]
fig, ax = plt.subplots()
ax.bar(studyminutesdf_week['Date'], studyminutesdf_week['Studyminutes'])
ax.set_title("Study minutes in a week")
ax.set_xlabel("Date")
ax.set_ylabel("Study minutes")
fig, ax = plt.subplots()
ax.bar(studyminutesdf['Date'], studyminutesdf['Studyminutes'])
ax.set_title("Study minutes in a month")
ax.set_xlabel("Date")
ax.set_ylabel("Study minutes")
ax.set_xticklabels(studyminutesdf['Date'], rotation = 90)
ax.axhline(y=30, linestyle='--', color='gray')
ax.axhline(y=np.mean(studyminutesdf['Studyminutes']), linestyle='--', color='black')
studyminutes_sortm_df = studyminutesdf.sort_values('Studyminutes', ascending=False)
fig, axes = plt.subplots(2, 1, tight_layout=True, figsize=(6, 9))
axes[0].bar(studyminutes_sortm_df['Date'], studyminutes_sortm_df['Studyminutes'])
axes[0].set_title("Study minutes in a month")
axes[0].set_xlabel("Date")
axes[0].set_ylabel("Study minutes")
axes[0].set_xticklabels(studyminutes_sortm_df['Date'], rotation = 90)
table = axes[1].table(cellText=studyminutes_sortm_df.values[:10],
colLabels=studyminutes_sortm_df.columns[:10],
loc='center', cellLoc='center',
colColours=['#808080', '#808080', '#808080'],
bbox=[0, 0, 1, 1],
)
table.auto_set_font_size(False)
table.set_fontsize(15)
axes[1].axis('off')
studyminutes_sortm_df = studyminutesdf.sort_values('Studyminutes', ascending=False)
studyminutes_sortm_df['Date']
fig, ax = plt.subplots()
ax.bar(studyminutes_sortm_df['Date'], studyminutes_sortm_df['Studyminutes'])
ax.set_title("Study minutes in a month")
ax.set_xlabel("Date")
ax.set_ylabel("Study minutes")
ax.set_xticklabels(studyminutesdf['Date'], rotation = 90)
studyminutes_dict = dict(zip(studyminutes_sortm_df['Date'], studyminutes_sortm_df['Studyminutes']))
# DateとStudyminutesによる辞書