2.4. Different Size Images and Titles

Let's say we want our plot to be bigger, 800 pixels wide and 600 pixels high. So instead of having the line

$plot = new PHPlot;

We replace it with

$plot = new PHPlot(800,600);

and you have specified the size in pixels of the image to be created.

A couple of things to note:

OK, now we're ready to add some customization to the plot. Let's change the size, the title and the X/Y axis labels. All we need to do is use additional methods of the $plot object before printing the image. Here is the complete result:

//Include the code
require_once 'phplot.php';

//create a PHPlot object with 800x600 pixel image
$plot = new PHPlot(800,600);

//Define some data
$example_data = array(

//Set titles
$plot->SetTitle("A Simple Plot\nMade with PHPlot");
$plot->SetXTitle('X Data');
$plot->SetYTitle('Y Data');

//Turn off X axis ticks and labels because they get in the way:

//Draw it

And that's it! What we get is the following graph:

Line graph with titles and labels

Note that the newline character "\n" separates multiple lines in titles, and you must use double quotes around the title string for PHP to recognize the newline.

SourceForge.net Logo

This version of the manual was produced for the PHPlot Sourceforge project web service site, which requires the logo on each page.

To download a logo-free copy of the manual, see the PHPlot project downloads area.