poss:

I tried your example (including the lines you left out) and see the difference between the two graphs. However, I can't figure out what you mean when you ask "How do I get the values to follow the bars?" Care to elaborate?

In the future, you'll get better answers if you make your code function so people can try it without having to finish and/or debug it. (The only reason I bothered is that I need to generate some bar charts for my current project at work.)

A working example, if anyone is interested:

#!/usr/bin/env perl use strict; use warnings; use GD::Graph; use GD::Graph::bars; my @data = ( [ 'Windows', 'Linux', 'Solaris' ], # Swap the next two lines to switch versions of the graph [ 150, 250, 350 ], [ 100, 200, 300 ], ); my $x_Label = "XLabel"; my $Graph_Title = "Graph Title"; my $graph = new GD::Graph::bars(900,600); $graph->set( x_label => $x_Label, x_label_position => 1/4, x_label_vertical => 1, y_label => 'Minutes', y_max_value => 300, y_tick_number => 10, title => $Graph_Title, bar_width => 35, cumulate => 1, dclrs => [ 'blue','cyan' ], bgclr => 'white', fgclr => 'lred', values_vertical => 0, valuesclr => 'black', accentclr => 'red', shadowclr => '#F7E7CE', shadow_depth => 0, legendclr => 'blue', show_values => 1 ); my $gd = $graph->plot(\@data) or die $graph->error; open my $IMG, '>', 'file2.png' or die $!; binmode $IMG; print $IMG $gd->png;

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re: perl bar graph by roboticus
in thread perl bar graph by poss

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.