使用此代码,我可以绘制出原本应该的点,但我不想让它显示每个用户的线(如股票图中的线)。在图中,x轴是时间变量,使用随机生成器函数分配其值,然后y值是在第二个for循环内计算出的用户奖励。由于在修复此图后它将变成更大的脚本,因此,测试值的示例为:“存放的数量” = 1000,“包装数量” = 10和“用户数量” =10。这些值仅用于测试目的,因此我可以使用图形输出。有什么建议可以使线条显示出来吗?
import random
from random import randint
from numpy import *
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
plt.figure(figsize = (8,5))
def grap():
MEU = 1
deposit = eval(input("How much tokens are going to be deposited to the
Rewards Pool?: "))
packages = eval(input("What is the number of packages in the Rewards
Period?: "))
#Number of users
num_users = eval(input("What is the number of users? "))
TEU = 0
user_reward = []
time = []
for i in range(num_users):
user_stake = random.randint(1,5)
if user_stake >= MEU:
UEU = user_stake / MEU
fixed_per_package = deposit / packages
for j in range(packages):
TEU += UEU
user_reward = (UEU / TEU) * fixed_per_package
time=random.randint(1,10)
plt.plot(time, user_reward, 'o-', linestyle='solid')
print("The total amount of rewards for user " + str(i+1) + " is: " + str(user_reward))
else:
print("The user " + str(i+1) + " will not receive any rewards.")
plt.title("User Information")
plt.xlabel("Time")
plt.ylabel("User Rewards")
plt.show()
graph()