[問題] 關於畫圖,GD畫圖

看板Perl作者 (李崩子)時間13年前 (2010/11/22 19:43), 編輯推噓0(003)
留言3則, 2人參與, 最新討論串1/2 (看更多)
=====以下是程式碼===== #!/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

11/23 01:39, , 1F
作法你不是自己列出來了嗎?
11/23 01:39, 1F

11/23 02:52, , 2F
可是我真正的輸入是未知數,我只是先用記事本代替
11/23 02:52, 2F

11/23 02:53, , 3F
就是程式裡本身不能改,能改的就是記事本
11/23 02:53, 3F
文章代碼(AID): #1CwbTOZq (Perl)
文章代碼(AID): #1CwbTOZq (Perl)