Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

GD::Graph labeling

by chinman (Monk)
on May 24, 2001 at 06:52 UTC ( #82801=perlquestion: print w/replies, xml ) Need Help??

chinman has asked for the wisdom of the Perl Monks concerning the following question:

Hey, I'm in need of some Monk wisdom. I've been dorking around with GD::Graph to try to plot an x,y line graph with lots o' points (>1000). I've got the basics working fine. Well, I'd like to label the maxima, or maybe the 10 biggest y values by using the show_values option. The problem is if I turn labeling on with my "thousand points of light" I've got way too many data point labels and everything runs together. I'm wondering if anyone knows a way to label just a few without blowing away the rest of the points. I've tried using the $data->copy method, followed by setting values to undefined but that does not appear to do what I want. It seems like when you say show_values it always wants to show_values for all data points. Thanks in advance for the help!

Replies are listed 'Best First'.
Re: GD::Graph labeling
by Prof Avery (Novice) on May 25, 2001 at 03:44 UTC
    Try using values_format, formatting the maxima as numbers and everything else as an empty string, e.g.
    sub v_format { my $value = shift; if ($value >= ($MAX - $EPSILON)) { return $value } else { return ''; } $my_graph->set('values_format' => \&v_format);
      Prof Avery,

      Thanks, that was a huge help! Somehow, values_format did not come up on my radar screen.

      Regards,

      chinman

Re: GD::Graph labeling
by ryddler (Monk) on May 24, 2001 at 18:14 UTC
    If I'm reading your post correctly, take a look at these values in the docs for GD::Graph
    x_label_skip, y_label_skip Print every x_label_skipth number under the tick on the x axis, and every y_label_skipth number next to the tick on the y axis. Default: 1 for both.
    Update:
    I misread this question, but the settings I pointed out above are still useful for some graphing ops, so I'll leave the post intact.

    ryddler
      ryddler, Thanks for your post. Yeah, what I'm looking to do is label certain points on the graph (like the maximum Y values). I've got the tic labeling figured out. While I'm on this topic...are there any monk recommendations for another graphing module that do a better job at what I'm trying to do? Basically, I'm taking spectra which contain thousands of x, y data points and I just want to do some automated labeling of some of the biggest peaks. Thanks... chinman

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2022-10-06 01:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (26 votes). Check out past polls.

    Notices?