Gnuplot with parametric scripts combined with Python scripts

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.