phpPlot is a free PHP utility that can plot a number of ordered pairs on a two-dimensional coordinate plane. It features the following functions:
- Display data as vertical or horizontal bars, points of various shapes, or lines.
- All colors (background, scale, data points) can be adjusted
- Scale labels (integer, float, date) can be adjusted)
- Automatic scaling that can be overridden manually.
- Multiple data rows graphed together, each with their own style
- Draw linear regression
- Draw means (both vertical and horizontal) and standard deviation areas
The sources are available on GitHub at git://github.com/cburschka/phpplot.git.
An example of how to use phpPlot
This image is generated by phpPlot.
This code was used to generate the picture.
require_once "phpplot/main.php"; // Load the phpPlot library
// Create a graph area sized 300x200, background light grey, text black
$graph = new Graph (300, 200, "ddd", "000");
// Display data as triangles of radius 4, colored red.
$style = new StylePolyPoint(3, 4, "f00");
// Create a data row named "Sample Data", styled as above.
$data_row = new DataRow("Sample Data", $style);
$data_row->addPoint(0, 1.2, "Point A"); // x, y, Label
$data_row->addPoint(2, 2.4, "Point B");
$data_row->addPoint(4, 6.9, "Point C");
$graph->addDataRow($data_row); // Add data row
$image = base64_encode($graph->draw_image());
header('Content-type: image/png'); // Send the mime header to the browser.
print $graph->draw_image(); // Draw image and send to browser.