Because the paper needs to use gnuplot mapping, and I like to use Python to generate data, so I studied the next gnuplot with the parameters of the script, so I can generate data at the same time call gnuplot, the implementation of a lot of methods, here I only say this.
1 Reset 2 set term PNG 3 Set Output Output_fname 4 Plot input_fname using 1:2 w LP PT 0 title ' Data '
Above is a simple line chart of the gnuplot script, the parameters are the inside of the Output_fname and Input_fname, the script needs to be called in the command line to specify these two parameters,
1 #-*-coding:utf-8-*-2 " "3 @Time: 2018/6/28 14:414 @Author: [email protected]5 @Site:6 @File: blog.py7 @Software: Pycharm8 " "9 ImportNumPy as NPTen fromSubprocessImportPopen One ImportOS A -Predir =OS.GETCWD () -env =Os.environ the Print(env) - Print(Os.get_exec_path (env)) -A = Np.random.standard_normal (10) -f = open (Os.path.join (Predir,"Data.txt"),"W") + forIinchRange (10): -F.write ("{} {}\n". Format (i, A[i])) + f.close () A atIn_path ="\ '"+os.path.join (Predir,"Data.txt")+"\ '" -Out_path ="\ '"+os.path.join (Predir,"Data.png")+"\ '" -cmd = ['gnuplot', - '- e', - "input_fname="+ In_path +"; Output_fname="+ Out_path +"", -Os.path.join (Predir,"PLOT.PLT") in ] -Popen (CMD)
Line 23rd through 30 is the execution of the script, which uses Popen to execute the command line.
The effect is as follows:
Gnuplot with parametric scripts combined with Python scripts