Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

GD::Graph line problem

by ultibuzz (Monk)
on Dec 18, 2006 at 13:39 UTC ( #590429=perlquestion: print w/ replies, xml ) Need Help??
ultibuzz has asked for the wisdom of the Perl Monks concerning the following question:

Hello,
i have a graph with dates as x ticks and i only want to schow 20 ticks on the axe.
i tryed now label skip and offset but didn't work,with max ticks i can not work because its not numerical.

DATA
___DATA.txt___ 01.10,75034 02.10,75722 03.10,75717 04.10,76427 05.10,76669 06.10,77256 07.10,77155 08.10,77135 09.10,77443 10.10,78347 11.10,78776 12.10,79252 13.10,79980 14.10,79945 15.10,79913 16.10,80451 17.10,80869 18.10,81144 19.10,81129 20.10,81625 21.10,81602 22.10,81599 23.10,82508 24.10,83697 25.10,84712 26.10,86267 27.10,87164 28.10,86921 29.10,86915 30.10,87913 31.10,88536 01.11,88598 02.11,89824 03.11,90815 04.11,90653 05.11,90620 06.11,91661 07.11,92231 08.11,93556 09.11,94816 10.11,96083 11.11,95969 12.11,95967 13.11,97054 14.11,97660 15.11,98428 16.11,98386 17.11,98308 18.11,98093 19.11,98088 20.11,98783 21.11,99311 22.11,100030 23.11,100630 24.11,100089 25.11,99854 26.11,99849 27.11,101942 28.11,102804 29.11,103813 30.11,105188 01.12,106007 02.12,105982 03.12,105982 04.12,106672 05.12,107552 06.12,108083 07.12,108101 08.12,107792 09.12,107726 10.12,107699 11.12,107708 12.12,107693 13.12,107551 14.12,107275 15.12,107247 16.12,107246 17.12,107240

and here is the code

#!"C:\perl\bin\perl.exe" use DBI; use POSIX qw(strftime); use GD::Graph::lines; use GD::Graph::colour; use GD::Text; use GD::Graph::Data; use warnings; use strict; my $data = GD::Graph::Data->new(); $data->read(file => "data.txt", delimiter => ','); my $graph = new GD::Graph::lines( 800, 600 ); $graph->set_title_font('arial.ttf', 20); $graph->set_values_font('arial.ttf', 5); $graph->set_x_label_font('arial.ttf', 12); $graph->set_y_label_font('arial.ttf', 12); $graph->set_x_axis_font('arial.ttf', 8); $graph->set_y_axis_font('arial.ttf', 12); $graph->set( y_label => 'Active', title => '===> flow <===', y_max_value => 120000, y_min_value => 70000, y_tick_number => 10, y_lable_skip => 2, x_tick_offset => 15, transparent => 1, values_vertical => 1, show_values => 1, line_width => 2, dclrs => [ qw(red)] ); my $gd = $graph->plot( $data ); open(IMG, ">chart.gif") or die $!; binmode IMG; print IMG $gd->gif; close IMG;

kd ultibuzz

Comment on GD::Graph line problem
Select or Download Code
Re: GD::Graph line problem
by jettero (Monsignor) on Dec 18, 2006 at 13:52 UTC

    "i can not work because its not numerical."

    Hrm. Are you attaching your "data.txt" to the end of your program as __DATA.txt__? The reason I ask is that I don't think that works...

    If not, then: Does your file literally contain "DATA\n\n___DATA.txt___\n?" If it does, that may be the problem. I can't be sure, without pulling the module off CPAN, but GD::Graph::Data probably doesnt' know how to handle malformated lines. UPDATE: I tried GD:G:D on a file with and without malformated lines and it didn't seem to complain. Perhaps you could elaborate on the problem?

    Lastly, if you shortened your data file example to say 5 or 10 lines, I bet folks would really appreciate the lower wear and tear on their mouse wheels.

    -Paul

      Hi, its an file named data.txt
      and i put this in readmore brakets, hmm maybe i make it wrong

      i want all informations from the file but only 10 x values on the axe, because reading 78 values in a 800*600 graph will not work.
      i want it more like y_tick_number, but this didn't work for x if x is not numerical.
      kd ultibuzz

        Oh, I see. I may have missed the question. I think you just want x_tick_number => 10.

        -Paul

Re: GD::Graph line problem
by ultibuzz (Monk) on Dec 20, 2006 at 16:00 UTC

    so anyone have a idear to get this done with non numerical X values ?
    kd ultibuzz

      x_long_ticks => 0, x_label_skip => 5,

      with this code it works, but only when i don't use x_offset.
      kd ultibuzz

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://590429]
Approved by chargrill
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2014-08-01 08:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (257 votes), past polls