PHPlot — Construct a new PHPlot Class Object


$plot = new PHPlot([$width], [$height], [$output_file], [$input_file])


This is the class constructor for PHPlot. It creates a new plot object and initializes all internal settings to default values.



Optional width of the plot image, in pixels. Default is 600.


Optional height of the plot image, in pixels. Default is 400.


Optional name of a file where the image output will be written. This is the same as using SetOutputFile. Default is no output file, meaning the image is written to standard output (that is, sent back to the browser).


Optional name of a file to use as a starting image. This becomes the background for the plot. If an input_file is given, any width and height given to the constructor are ignored, and the size of the image in the named input_file are the plot image size. Default is no input file, meaning a blank image will be created at the given or default width and height.

Return Value

Returns an object, an instance of the PHPlot class.


The output_file will be ignored unless SetIsInline(True) is called.

If no input_file is supplied, the PHPlot constructor creates a palette plot image, and the PHPlot_truecolor constructor creates a truecolor plot image. If an input_file is supplied, the two constructors are equivalent, and the type of the input file (truecolor or palette) determines the type of the plot image.


Earlier versions of this manual said that the created object should always be returned as a reference, like this:

$plot =& new PHPlot(...);  // Do not use this

This was because PHPlot included a function to deallocate memory used by the object at script shutdown, but that would only work if a reference assignment was used. This quasi-destructor was removed at PHPlot-5.0.4 because it interfered with memory deallocation until the script ended. So the reference assignment should not be used. In addition, reference assignment of a newly created object instance is deprecated starting with PHP5, and removed in PHP7. 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.