2017-10-08 18 views
-1

私はPerlのGD::Graphモジュールを使って信号プロファイルをプロットしています。何らかの理由でy軸と最初にプロットされた点の間に刺激的で望ましくない隙間があるという点を除いて、ほとんどすべてを正しいものにすることができました。どうすればこの問題を解決できますか?Perl - GD ::グラフ - プロットとy軸のギャップ

私が書いたテストページのコードです(私のlocalhostサーバに表示されますが、私はライブサーバにインストールしてみましたので、他の人が結果を見ることができるようになりました。私のライブのサイトから欠落しているいくつかのPerlモジュール):

#!perl 

use POSIX; 
use CGI ':standard'; 
use GD::Graph::area; 
use GD::Graph::colour qw(:colours); 

use strict; 

# Graph constants 
GD::Graph::colour::add_colour(axes => [ 0x00, 0x00, 0x00 ]); 
GD::Graph::colour::add_colour(earth => [ 0x00, 0x00, 0x00 ]); 
GD::Graph::colour::add_colour(beam => [ 0x00, 0x00, 0x00 ]); 
GD::Graph::colour::add_colour(clutter => [ 0x66, 0x33, 0x00 ]); 
GD::Graph::colour::add_colour(terrain => [ 0x00, 0x99, 0x00 ]); 
GD::Graph::colour::add_colour(earth => [ 0x00, 0x00, 0x00 ]); 
GD::Graph::colour::add_colour(fre1 => [ 0xFF, 0x33, 0x00 ]); 
GD::Graph::colour::add_colour(fre2 => [ 0xFF, 0x66, 0x00 ]); 
GD::Graph::colour::add_colour(sky1 => [ 0x33, 0x66, 0x99 ]); 
GD::Graph::colour::add_colour(sky2 => [ 0x66, 0x99, 0xCC ]); 

# All arrays should same number of entries. 
my @data = (
    [ 0, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, 5, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, 10, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, 15, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, 20, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, 25, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, 30, undef, undef, undef, undef, undef, undef, undef, undef, undef ], 
    [ 450, 458, 459, 458, 457, 455, 453, 451, 449, 447, 444, 441, 438, 435, 432, 429, 426, 422, 420, 416, 413, 409, 406, 402, 399, 395, 391, 388, 384, 381, 376, 373, 369, 365, 361, 358, 353, 350, 345, 341, 337, 333, 329, 325, 321, 316, 313, 308, 304, 299, 296, 291, 286, 282, 277, 273, 268, 265, 259, 256, 250, 247, 241, 236, 232, 227, 223, 217, 213, 208, 204, 198, 194, 188, 184, 178, 173, 168, 163, 158, 152, 148, 142, 137, 131, 126, 120, 115, 109, 102, 97, 90, 85, 78, 72, 64, 58, 50, 43, 32 ], 
    [ 450, 453, 451, 449, 447, 444, 441, 438, 435, 432, 428, 426, 422, 418, 415, 411, 408, 404, 400, 396, 393, 389, 386, 381, 378, 374, 369, 366, 361, 358, 353, 350, 345, 342, 337, 334, 329, 326, 321, 316, 313, 308, 305, 300, 296, 291, 288, 283, 279, 274, 271, 266, 261, 257, 252, 249, 244, 240, 235, 231, 226, 222, 217, 212, 208, 203, 199, 194, 190, 185, 181, 176, 172, 166, 162, 157, 151, 147, 142, 138, 132, 128, 123, 118, 113, 108, 103, 98, 92, 87, 82, 76, 71, 65, 60, 54, 49, 42, 36, 27 ], 
    [ 450, 445, 440, 436, 432, 428, 423, 419, 414, 411, 406, 402, 397, 392, 389, 384, 380, 375, 372, 367, 363, 358, 354, 350, 346, 341, 336, 332, 328, 324, 319, 315, 310, 307, 302, 298, 293, 290, 285, 280, 276, 271, 268, 263, 259, 254, 250, 246, 242, 237, 233, 228, 224, 220, 215, 211, 206, 203, 198, 194, 189, 186, 181, 176, 172, 167, 164, 159, 155, 150, 147, 142, 138, 133, 129, 125, 120, 116, 111, 107, 102, 99, 94, 90, 85, 82, 77, 73, 68, 63, 60, 55, 51, 46, 43, 38, 34, 29, 25, 21 ], 
    [ 450, 437, 429, 423, 416, 411, 405, 400, 394, 389, 383, 379, 373, 367, 363, 357, 353, 347, 343, 337, 333, 328, 323, 318, 314, 309, 303, 299, 294, 290, 285, 281, 275, 272, 266, 262, 257, 253, 248, 243, 239, 234, 231, 226, 222, 217, 213, 208, 205, 200, 196, 191, 186, 183, 178, 174, 169, 166, 161, 157, 153, 149, 144, 140, 136, 132, 128, 124, 120, 116, 112, 108, 104, 100, 97, 92, 88, 84, 80, 77, 73, 69, 65, 62, 58, 55, 51, 48, 44, 40, 37, 34, 31, 27, 25, 22, 19, 17, 15, 14 ], 
    [ 450, 432, 422, 415, 406, 400, 393, 387, 380, 375, 368, 363, 357, 350, 345, 339, 334, 328, 324, 318, 313, 307, 303, 297, 293, 287, 281, 277, 271, 267, 262, 258, 252, 248, 243, 239, 233, 229, 224, 219, 215, 210, 206, 201, 197, 192, 188, 183, 180, 175, 171, 166, 161, 158, 153, 149, 145, 141, 136, 133, 128, 125, 120, 116, 112, 108, 105, 100, 97, 93, 89, 85, 82, 78, 75, 71, 67, 64, 60, 57, 53, 50, 46, 43, 40, 37, 34, 31, 28, 25, 22, 19, 17, 15, 13, 11, 10, 8,  8,  9 ], 
    [ 387, 344, 266, 240, 222, 215, 190, 156, 120, 76, 99, 151, 167, 158, 167, 158, 157, 148, 114, 89, 87, 28, 11, 11, 12, 12, 12, 13, 13, 13, 13, 23, 15, 34, 39, 38, 72, 107, 122, 134, 128, 128, 121, 100, 82, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 20, 20, 15, 15, 15, 15, 14, 14, 14, 14, 60, 53, 13, 13, 12, 12, 12, 12, 11, 11, 11, 10, 10, 9,  9,  9,  8,  8,  7,  7,  6,  6, 5,  5,  4,  4,  3,  2,  2,  1,  26 ], 
    [ 386, 343, 261, 235, 217, 210, 185, 151, 105, 61, 84, 136, 152, 143, 152, 153, 152, 143, 109, 84, 82, 23, 11, 11, 12, 12, 12, 13, 13, 13, 13, 23, 15, 34, 34, 33, 67, 102, 117, 129, 123, 128, 121, 100, 82, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 60, 53, 13, 13, 12, 12, 12, 12, 11, 11, 11, 10, 10, 9,  9,  9,  8,  8,  7,  7,  6,  6, 5,  5,  4,  4,  3,  2,  2,  1,  26 ], 
    [ 0, 1,  1,  2,  3,  3,  4,  4,  5,  5,  6,  6,  7,  7,  8,  8, 9,  9,  9,  10, 10, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9,  9,  8,  8,  8,  7,  7,  6,  6, 5,  5,  4,  4,  3,  2,  2,  1,  1 ] 
); 

my $dist = 32.745; 

my $mygraph = GD::Graph::area->new(800, 300); 

$mygraph->set(
    transparent  => 0, 
    l_margin   => 3, 
    b_margin   => 3, 
    t_margin   => 5, 
    r_margin   => 5, 
    text_space  => 3, 
    axis_space  => 7, 
    tick_length  => -5, 
    accent_treshold => 100, 
    x_label_position => 0.5, 
    bgclr    => 'white', 
    fgclr    => 'black', 
    boxclr   => 'sky1', 
    labelclr   => 'black', 
    axislabelclr  => 'black', 
    textclr   => 'black', 
    x_label   => 'Kilometres', 
    y_label   => 'Metres', 
    x_label_skip  => 15.27, 
    x_last_label_skip => 1, 
    x_min_value  => 0, 
    x_max_value  => $dist, 
    borderclrs  => [qw(fre2 fre1 black fre2 sky1 clutter terrain axes)], 
    dclrs    => [qw(fre2 fre1 fre1 fre2 sky1 clutter terrain axes)] 
) or warn $mygraph->error; 

my $myimage = $mygraph->plot(\@data) or die $mygraph->error; 

print "Content-type: image/png\n\n"; 

print $myimage->png; 

背景情報は

私は現在、所定の送信機への空中地上波TVを揃えるために、英国の市民を可能に非常に成功したWebページを持っています。 Here's an example of it in action

ロードが完了し、関連するボタンが有効になったら、そこに空中を整列させ、信号の可能性が高い有用性を予測するのに役立つ3つの利用可能なビジュアルコンポーネント:

  • にランドマークを見つけるためのGoogleマップ
  • 潜在的な障害物を
を示す垂直信号プロファイルを信号経路を示す英国陸地測量地図
  • に向かって空中を指し0

    フォームの末尾にあるシグナルプロファイルボタンを押すことによって得られた最後のもので、2つのマップの下のページ下部に表示されます。現在GoogleツールツールGoogle Chart Tools APIを使用しており、残念ながらGoogleによって廃止され、2015年に終了するはずですが、幸運にもこれまでのところ実行し続けているため、置き換える予定です。

    私はGoogleがスイッチをスローするが、非常に限られた成功を収めていたその日に来ています。誰かが自分のサーバにインストールしてGoogleのチャート描画機能を置き換えることができるパッケージを知っていれば、それについて知っていただければ幸いです。

  • +0

    で一度に一つだけ質問してください。 – Borodin

    +3

    すべてのPerlファイルを 'use strict;警告を使う; '。 – melpomene

    答えて

    1

    このコードでは、オフラインでエラーが発生しているように感じますが、今はさらに調査する時間がありません。私はちょうど仕事は、周りに置き換えることであると考えられることに注意しましょう:

    x_min_value  => 0, 
    

    x_min_value  => 1, 
    
    +0

    ありがとうございますが、データの終わりからプロット領域の端までの間の右端にもギャップがあることがわかりました。この提案は実際にはプロットを左に移動させますが、結果的に右のギャップはそれに応じて増加します。 – CharlesMacfarlane

    関連する問題