看板 Perl 關於我們 聯絡資訊
=====以下是程式碼===== #!/usr/local/bin/perl -w use CGI ':standard'; use GD::Graph::lines; open (FH,"02.txt")||die"File open Error!\n"; my @file = map { chomp; split(/\t/) } <FH>; @num=(1..$#file+1);#定義X軸的值 @data = ([@num], [@file] ); my $mygraph = GD::Graph::lines->new(900, 300); $mygraph->set( x_label => 'X', y_label => 'Y', title =>'Test', # Set the thickness of line line_width => 1, ) ;#or warn $mygraph->error; my $myimage = $mygraph->plot(\@data) or die $mygraph->error; binmode STDOUT; print $myimage->png; =================== 以下是我執行後。 C:\>perl GD99.pl >test.png 然後test.png 長這樣 http://ppt.cc/ZIi, 然後我的記事本的內容是這樣 10 9 8 7 6 8 201 190 180 170 160 155 176 就是2行數。 我最後是希望能有2條曲線,可是我再怎麼弄都是一條,而且是全部的值拿去畫 如果是要寫死是這樣 @data = ([1,2,3,4,5,6,7],#這是X [10,9,8,7,6,8],#之後都是Y [201,190,180,170,160,155,176], [...]#依此類推。 ); .. . 在這先說聲謝謝。 -- -- ▂▂ ▂▂▂ ▂▄▅▅▄▆█ _█◣ ◢ (●) ◣/\\ 丫 │◥  ̄◤ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.215.116
cibs:作法你不是自己列出來了嗎? 11/23 01:39
sqrt1089:可是我真正的輸入是未知數,我只是先用記事本代替 11/23 02:52
sqrt1089:就是程式裡本身不能改,能改的就是記事本 11/23 02:53