http://www.perlmonks.org?node_id=590429

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