projectEli/Database/progress/chart.py

44 lines
1.3 KiB
Python
Raw Permalink Normal View History

import matplotlib.pyplot as plt
import pandas as pd
# Read the data from the CSV
data = pd.read_csv('data/exp.csv')
#line
# Create a line chart
plt.figure(figsize=(12, 6))
plt.plot(data['lv'], data['xp'], marker='o', linestyle='-', color='b')
plt.title('Experience Points Needed for Each Level')
plt.xlabel('Level')
plt.ylabel('Experience Points')
plt.grid(True)
plt.show()
#bar
plt.figure(figsize=(12, 6))
plt.bar(data['lv'], data['xp'], color='b')
plt.title('Experience Points Needed for Each Level')
plt.xlabel('Level')
plt.ylabel('Experience Points')
plt.grid(axis='y')
plt.show()
#area
plt.figure(figsize=(12, 6))
plt.fill_between(data['lv'], data['xp'], color='b', alpha=0.5)
plt.plot(data['lv'], data['xp'], color='b', marker='o')
plt.title('Cumulative Experience Points Needed for Each Level')
plt.xlabel('Level')
plt.ylabel('Experience Points')
plt.grid(True)
plt.show()
# Calculate the difference in xp from the previous level
data['xp_diff'] = data['xp'].diff()
data['xp_diff'].iloc[0] = 0 # Set the first value to 0 as there's no previous level
# Create a line chart for xp difference
plt.figure(figsize=(10, 6))
plt.plot(data['lv'], data['xp_diff'], marker='o', linestyle='-', color='b')
plt.title('Experience Point Difference from Previous Level')
plt.xlabel('Level')
plt.ylabel('Experience Point Difference')
plt.grid(True)
plt.show()