Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3302390
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:50:48+00:00 2026-05-17T20:50:48+00:00

I have an array with a few elements: MSN = 34.3433423432434% Chrome = 12.4343434353534%

  • 0

I have an array with a few elements:

MSN = 34.3433423432434%

Chrome = 12.4343434353534%

Gtalk = 32.23233543543532%
…

And I’m passing this array as y-axis labels to use with a module called GD::Graph. The problem I am facing right now, is that the number are so big on the graph that they overlap with the adjacent entry and make it unreadable.

Is there a way where I can round off ALL the elements in an array to just 2 decimal places? And make it xx.xx%?


Also, anyone familar with using GD::Graph, do you know how can I increase the text-size on the graph? I can increase Title / Legend size fine, but the actual text as in ‘Gtalk’ or ‘32.23233543543532%’ is really small and I’ve tried a lot of the commands from http://search.cpan.org/dist/GDGraph/Graph.pm, but they don’t seem to work for me!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:50:48+00:00Added an answer on May 17, 2026 at 8:50 pm
    #!/usr/bin/perl
    
    use strict; use warnings;
    use YAML;
    
    my %x = (
        MSN => '34.3433423432434%',
        Chrome => '12.4343434353534%',
        Gtalk => '32.23233543543532%',
    );
    
    for my $x ( values %x ) {
        $x =~ s/^(\d+\.\d+)%\z/ sprintf '%.2f%%', $1/e;
    }
    
    print Dump \%x;
    

    Output:

    Chrome: 12.43%
    Gtalk: 32.23%
    MSN: 34.34%

    If you want to extract values in a specific order, use a hash slice:

    print "@x{ qw( MSN Chrome Gtalk ) }\n";
    

    or, if you just want keys and values to line up in the plot call:

    my $gd = $graph->plot([
        [ keys %x ],
        [ @x{ keys %x } ],
    ]) or die $graph->error;
    

    Note: To increase the text size on a GD::Graph, use a larger font for the element. See Methods for charts with axes.

    Using GD::Graph, you really should not have to modify the values yourself. Just provide the string '.2f%%' as the argument to y_number_format.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an arrays.xml file containing quite a few string-array elements for use with
I have an array list containing few elements. What i want to do is
I have put few elements in array (e.g. 5 elements) The first element, index[0]
I have an array of elements. This array could be: Randomly shuffled (about 20%
I have few arrays of integers. Elements in each array are ordered. Arrays does
Hey I have an array where each element is a hash containing a few
I have populated an array with a few html image tags that I have
I'm progamming in javascript/jQuery. Say, I have an array with includes a few number
I have a simple JavaScript Array object containing a few numbers. [267, 306, 108]
I have a few html image tags that fill an array. On the page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.