This commit is contained in:
JohnJim0816
2020-09-08 13:37:12 +08:00
parent 106cfcc714
commit ac98105833
12 changed files with 118 additions and 57 deletions

View File

@@ -5,39 +5,40 @@
@Email: johnjim0816@gmail.com
@Date: 2020-06-11 16:30:09
@LastEditor: John
@LastEditTime: 2020-06-12 11:34:52
LastEditTime: 2020-09-02 01:20:03
@Discription:
@Environment: python 3.7.7
'''
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns; sns.set()
import seaborn as sns;
import numpy as np
import os
# def plot(item,ylabel='rewards'):
# plt.figure()
# plt.plot(np.arange(len(item)), item)
# plt.title(ylabel+' of DDPG')
# plt.ylabel(ylabel)
# plt.xlabel('episodes')
# plt.savefig(os.path.dirname(__file__)+"/result/"+ylabel+".png")
# plt.show()
def plot(item,ylabel='rewards'):
df = pd.DataFrame(dict(time=np.arange(500),
value=np.random.randn(500).cumsum()))
g = sns.relplot(x="time", y="value", kind="line", data=df)
g.fig.autofmt_xdate()
# time = range(len(item))
# sns.set(style="darkgrid", font_scale=1.5)
# sns.lineplot(time=time, data=item, color="r", condition="behavior_cloning")
# # sns.tsplot(time=time, data=x2, color="b", condition="dagger")
# plt.ylabel("Reward")
# plt.xlabel("Iteration Number")
# plt.title("Imitation Learning")
def plot(item,ylabel='rewards',save_fig = True):
'''plot using searborn to plot
'''
sns.set()
plt.figure()
plt.plot(np.arange(len(item)), item)
plt.title(ylabel+' of DDPG')
plt.ylabel(ylabel)
plt.xlabel('episodes')
plt.savefig(os.path.dirname(__file__)+"/result/"+ylabel+".png")
plt.show()
# def plot(item,ylabel='rewards'):
#
# df = pd.DataFrame(dict(time=np.arange(len(item)),value=item))
# g = sns.relplot(x="time", y="value", kind="line", data=df)
# # g.fig.autofmt_xdate()
# # sns.lineplot(time=time, data=item, color="r", condition="behavior_cloning")
# # # sns.tsplot(time=time, data=x2, color="b", condition="dagger")
# # plt.ylabel("Reward")
# # plt.xlabel("Iteration Number")
# # plt.title("Imitation Learning")
# plt.show()
if __name__ == "__main__":
output_path = os.path.dirname(__file__)+"/result/"