gnuplot_i 文件的说明,翻译成的中文
生活随笔
收集整理的這篇文章主要介紹了
gnuplot_i 文件的说明,翻译成的中文
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
gnuplot_i的簡短介紹
------------------------------------
gnuplot_i正式應該稱為gnuplot管道,是一種友好的編程方式實現用C語言調用gnuplot畫圖.
畫圖的具體步驟操作如下:
1通過一個gnuplot_ctrl型指針,打開gnuplot,調用方式為gnuplot_init(),如下
??? gnuplot_ctrl * h ;
??? h = gnuplot_init() ;
h將被作為gnuplot工作區的指針,通過其它庫函數調用h(自己也可以給指針取不同的名字,以下用h作指針變量)
2.圖像參數設置如下? ?
??? gnuplot_setstyle(h, style)
?????? (設置畫圖風格)
??? gnuplot_set_xlabel(h, label)
??????? 設置x軸坐標
??? gnuplot_set_ylabel(h, label)
?????? 設置Y軸坐標
??? 例子:
??? gnuplot_setstyle(h, "impulses") ;
??? gnuplot_set_xlabel(h, "my X label") ;
??? gnuplot_set_ylabel(h, "my Y label") ;
最有用的套路,應該是gnuplot_cmd(),它允許你給gnuplot傳送特征的字符串,如下所示:
?? ?
??? gnuplot_cmd(h, command, ...)
??? 例子:
??? char myfile[] = "/data/file_in.dat" ;
??? int? i ;
?? ?
??? gnuplot_cmd(h, "plot '%s'", myfile);
??? for (i=0 ; i<10 ; i++) {
??????? gnuplot_cmd (h, "plot y=%d*x", i);
??? }
接下來的命令,需要輸出給postscript這種腳本語言文件curve.ps完成
? ?
??? gnuplot_cmd(h, "set terminal postscript") ;
??? gnuplot_cmd(h, "set output \"curve.ps\"") ;
? ?
??? 3.? 一些畫圖命令:
??? gnuplot_plot_slope()
??????? 畫一條斜線
??? gnuplot_plot_equation()
??????? 畫一個函數圖像
??? gnuplot_plot_x()
??????? 畫用戶給定數據的第一維,作為X軸,畫圖(單變量畫圖)
??? gnuplot_plot_xy()
??????? 畫兩個變量的圖
??? gnuplot_resetplot()
??????? 清除之前的畫圖
??? 4.? 關閉gnuplot指針變量:關閉此變量是非常重要的,否則其它畫圖產生的臨時文件將不會在緩存中刪除
??? gnuplot_close(h) ;
See examples of gnuplot_i use in the provided files
'example.c' and 'anim.c'.
Some more points before you start using gnuplot_i
-------------------------------------------------
??? gnuplot_i is completely free software. Use it for
?? ?whatever you want to do with it without any fee, and do not
?? ?hesitate to send feedback to me if you wish:
?? ?
??????? <ndevilla@free.fr>
??? If you can do it, I would appreciate a mention somewhere
??? that you are using 'gnuplot_i' in your application.
??? Something like:
??? "This software uses the gnuplot_i library written by
??? N.Devillard <ndevilla@free.fr>
??? If you are using gnuplot_i for a web-based
??? application, you can also add a link to the gnuplot home
??? page:
??????? http://ndevilla.free.fr/gnuplot/
??? 注意:當在一個程序中需要寫打開多個畫圖對話框的時候,要注意函數與所打開對話框的對應關系
??? 例如:
??? h1 = gnuplot_init() ;
??? h2 = gnuplot_init() ;
??? gnuplot_plot_equation(h1, "sin(x)", "sine on first session");
??? gnuplot_plot_equation(h2, "log(x)", "log on second session") ;
??? sleep(3) ;
??? gnuplot_close(h1) ;
??? gnuplot_close(h2) ;
警告:不要忘記關閉對話框!
?? ?
? ?
編譯運行examples
-------------------------------
可以使用已經提供的Makefile文件進行編譯, 或者以如下方式進行編譯:
To compile the gnuplot_i module:
% cc -I. -c gnuplot_i.c
編譯兩examples:
% cc -o example example.c gnuplot_i.o
% cc -o anim anim.c gnuplot_i.o
使用Makefile進行編譯:
% make
% make tests
Try it out to see if it works:
% test/anim?? ??? ??? ??? ?-- Will show an animated sine wave
% test/example?? ??? ??? ?-- Will show various functions in use
% test/sinepng?? ??? ??? ?-- Will generate a PNG file with a sine wave
N. Devillard
總結
以上是生活随笔為你收集整理的gnuplot_i 文件的说明,翻译成的中文的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C语言从文件中读入矩阵,并且将矩阵转置
- 下一篇: C++中函数参数形式的总结