views:

529

answers:

3

I am drawing a graph using GD::Graph module in Perl.

I can draw the graph fine but in the drawn image I want to add some text around the top of the drawn graph image. Basically just want to add some text to this drawn image. However, I don't see an option to do that.

Does someone know if this is doable?

+1  A: 

The following article outlines methods to include text using GD::Graph. I think if you want to write on the graph itself you may not find anything useful in this article.

ojblass
A: 

Have you tried title?

From the USAGE section:

$graph->set( 
    x_label           => 'X Label',
    y_label           => 'Y label',
    title             => 'Some simple graph',
    y_max_value       => 8,
    y_tick_number     => 8,
    y_label_skip      => 2 
) or die $my_graph->error;

Edit:

Apparently I misunderstood the question, and the text should be overlayed on the chart area. In that case, the experimental get_feature_coordinates method can apparently be used to get "the coordinates of the rectangle within the axes", and from that you should know where you can draw directly on the GD::Image you get from $graph->plot(\@data)

Cebjyre
yeah i know abou the title attribute. However it shows on top of the main graph. I wanted to have a text somewhere between x and y axis
Ah, so you want the text overlayed on top of the actual chart area? It's probably worth clarifying that in your question.
Cebjyre
+2  A: 

Once you have the GD object, you can do anything that GD lets you do, including adding additional text:

$gd = $graph->plot( \@data );

$gd->string($font,$x,$y,$string,$color);

If you just want to add titles or axes labels, that's already built into GD::Graph.

brian d foy