Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

GD::Graph questions

by rpike (Scribe)
on Dec 02, 2010 at 21:45 UTC ( #875012=perlquestion: print w/replies, xml ) Need Help??
rpike has asked for the wisdom of the Perl Monks concerning the following question:

How do you change the font of the title and the x- and y-axis labels? I'd like the font to be about double the size it currently defaults to. Any help would be appreciated.

Replies are listed 'Best First'.
Re: GD::Graph questions
by ww (Archbishop) on Dec 02, 2010 at 21:59 UTC
    Did you read the docs,

    No?     Oh, sorry :-(

    - -
    Methods for charts with axes. $graph->set_x_label_font(font specification) $graph->set_y_label_font(font specification) $graph->set_x_axis_font(font specification) $graph->set_y_axis_font(font specification) $graph->set_values_font(font specification) Set the font for the x and y axis label, the x and y axis value la +bels, and for the values printed above the data points. See "FONTS".

    Yeah, may or may not do precisely what you want, but finding that took only a few seconds and there's a rather large part of the doc I haven't read.

    But my cursory effort also uncovered this which may even offer some code to cargo-cult.

Re: GD::Graph questions
by umasuresh (Hermit) on Dec 02, 2010 at 21:51 UTC
    Did you try the something like this?
    $graph->set_x_axis_font('/fonts/arial.ttf', 20); $graph->set_y_axis_font('/fonts/arial.ttf', 20);
    NOTE: untested! UPDATE: I tried the above and it doesn't work at least in Windows even after specifying the font path. However I tried odha57's suggestion in Using GD on MS Windows and this increased the font size.
    $graph->set_x_axis_font(GD::Font->MediumBold); $graph->set_y_axis_font(GD::Font->MediumBold);
    You may have look into GD::Font to be able to specify the exact font size. Good Luck!
      The title font is easy:
      $graph->set_title_font('/fonts/arial.ttf', 20);

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://875012]
Approved by ww
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2017-09-24 11:01 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (274 votes). Check out past polls.