Thx for the fast reply,
it's the same problem indeed, but unanswered for my use, don't wanne use bars for the application.
I think there's no direct option in the module to do shift the line to the edge... | [reply] |
Well the last reply in that node DID get the axis to shift to 0.
#!/usr/bin/perl
use warnings;
use strict;
use GD::Graph::lines;
# See: http://perlmonks.org?node_id=629955
use constant PI => 4 * atan2(1,1);
print STDERR "Processing sample55\n";
my @x = map {$_ * 3 * PI/100} (0 .. 100);
my @y = map sin, @x;
my @z = map cos, @x;
my @data = (\@x,\@y,\@z);
my $my_graph = new GD::Graph::lines(400,400);
$my_graph->set(
x_label => 'Angle (Radians)',
y_label => 'Trig Function Value',
x_tick_number => 'auto',
y_tick_number => 'auto',
title => 'Sine and Cosine',
line_width => 1,
x_label_position => 1/2,
r_margin => 15,
transparent => 0,
);
$my_graph->set_legend('Thanks to Scott Prahl');
my $gd = $my_graph->plot(\@data);
open (IMG, ">$0.png") or die $!;
binmode IMG;
print IMG $gd->png;
close IMG;
However, I tried to put your data into the exact same script, and it wouldn't go to 0...... I think GD::Graph::lines is buggy about this. I tried mapping your data, tried changing your text axis marks to numeric... (0,1,2,3).... and it still wouldn't shift. Very aggravating.
| [reply] [d/l] |
Hey,
I also need the exactly same thing. so I tried your sample.
I think, the sample also doesn't start from 0 (Y axis), just it looks like it due to 100 data. The interval between ticks is a very small, it look like none but actually there is.
You can reduce the data by changing
from:
my @x = map {$_ * 3 * PI/100} (0 .. 100);
To:
my @x = map {$_ * 3 * PI/100} (0 .. 10);
You will see it also has the space before drawing the line.
Thanks,
| [reply] |