title: Plotting graph in perl
body: <p><img src="https://i.stack.imgur.com/M64IW.gif" alt="first graph">graph 1
  <img src="https://i.stack.imgur.com/dhnPG.png" alt="graph2">I am very new to perl and plotting graph is something which i am learning. Here is a code.</p>
  
  <pre><code>@user_list = (sort { $user_list{$a} &lt;=&gt; $user_list{$b} } keys %user_list);
  @data = \@user_list;
  
  # Goes through the weeks and add each week info to the data array
  my $size = scalar @weeks;
      if ($size &gt; 4)
  {
      $start = $size - 4;
      print $start;
  }
  for my $i ($start..($size - 1))
  {
      my @week = @{$weeks[$size - $i - 1]};
      foreach my $x (@week) { $x = ceil($x / 7); }
      @data = (@data, \@week);
      }
  
  $graph = GD::Graph::bars-&gt;new(1200,600);
  
  $graph-&gt;set( 
      x_label =&gt; 'Weeks',
      y_label =&gt; 'Average Total Open Cases Per User',
      title =&gt; 'Alpha Cases Weekly Trend Per User',
      transparent =&gt; 0,
      bargroup_spacing =&gt; 3,
      show_values =&gt; 1
  );
      $graph-&gt;set_legend(@week_start_dates);
  $gd = $graph-&gt;plot(\@data);
  open(IMG, '&gt; /var/www/cgi-bin/remedy-case-management/graphs/Alpha_Cases.png') or die $!;
  binmode IMG;
  print IMG $gd-&gt;gif;
  close IMG;
  </code></pre>
  
  <p>I am troubleshooting a graph which shows first 4 weeks in x-axis.i.e 
    @week_start_dates=Jul-26-2014 Aug-02-2014 Aug-09-2014 Aug-16-2014 Aug-23-2014 Aug-30-2014 Sep-06-2014 Sep-13-2014</p>
  
  <p>So when I print the graph it shows the first 4 weeks from Jul 26 to Aug-16 as in the first graph in picture but I wanted to print Aug23-Sep13.</p>
  
  <p>So if I do not reverse the @week_start_dates it shows  as in the second graph:
  Sep-13-2014 Sep-6-2014 Aug-30-2014 Aug 23-2014 </p>
  
  <p>I do not know where exactly in the code it is trimming to display only 4 weeks.I want to print this in x-axis.
  Aug-23-104 Aug-30-2014 Sep-6-2014 Sep-13-2014</p>
  
  <p>Should I use @week_start_dates=substr function to display the last 4 weeks dates.?It's actually trimming only 4 weeks somewhere in the code and I am not able to find out that.Can help is much appreciated?</p>