Skip to content

Commit

Permalink
2161加入绘制曲线(略有点丑…)
Browse files Browse the repository at this point in the history
  • Loading branch information
GJZhou committed May 7, 2019
1 parent 7031931 commit 2a44762
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions Phylab/storage/app/script/p2160115.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
from handler import scriptdir
import xml.dom.minidom
import math
import sys
import matplotlib.pyplot as plt
import numpy as np

# 以上包必须引入,否则脚本无法运行
Expand Down Expand Up @@ -56,7 +58,7 @@ def handler(XML):
################### 自由发挥分割线 #######################
# 这里你可以自定义一些数据处理的方式,但最后一定要返回jinja2绑定好的文本!
data = read_xml(XML)
return process_data(data[0][0],data[1], source)
return process_data(data[0][0],data[1], source , sys.argv[3])


"""
Expand Down Expand Up @@ -120,7 +122,7 @@ def cat_q(u , t):

return data

def process_data(u , t , source):
def process_data(u , t , source , name):
# 以下例子做了简单的加法
#INPUT_A = data[0][0][0]
#INPUT_B = data[0][0][1]
Expand Down Expand Up @@ -153,6 +155,18 @@ def process_data(u , t , source):
#eta = [0,0,0,0,0,0]
#eta_f = 0
#ave_e = 0

font = {
'size' : 30 ,
}

pic = name + '_pic1'
for i in range(6):
plt.plot( [0,n[i]] , [0 , q[i]*1e19] ,linewidth = 1.0)
plt.xlabel('n' , font)
plt.ylabel('Q' , font)
plt.savefig(pic , bbox_inches='tight')

return env.from_string(source).render(
U = u,
t0 = t[0],
Expand Down Expand Up @@ -193,7 +207,8 @@ def process_data(u , t , source):
eta5 = eta[5],
eta = eta_f,
ave_e = ave_e,
U_a = ua
U_a = ua,
figurename = pic
)

'''
Expand Down

0 comments on commit 2a44762

Please sign in to comment.