Dois Gráficos na mesma imagem. PHPLot

Boa Tarde senhores,
Este post é pra (tavez) responder a uma duvida de um usuário, de como gerar dois gráficos PHPLot na mesma imagem.
Dei uma pesquisada e achei o seguinte exemplo na documentação Oficial:

Exemplo:

<?php
include('./PHPlot.php');  // here we include the PHPlot code
$graph =& new PHPlot(400,250);   // here we define the variable $graph
$graph->SetPrintImage(0); //Don't draw the image yet

//....Data and Values for first graph here .....

$graph->SetNewPlotAreaPixels(70,10,375,100);  // where to place it

$graph->DrawGraph();   //Draw the first graph to the image.

//....Data and Values for second graph here .....

$graph->SetNewPlotAreaPixels(70,120,375,220); //where to place graph 2
$graph->DrawGraph();  //Draw the second graph to the image

//Print the image with both graphs
$graph->PrintImage();
?>

Exemplo com dados:

<?php
//Include the code
include('./phplot.php');

//Define the object
$graph =& new PHPlot(400,250);

$graph->SetPrintImage(0); //Don't draw the image until specified explicitly

$example_data = array(
     array('a',3),
     array('b',5),
     array('c',7),
     array('d',8),
     array('e',2),
     array('f',6),
     array('g',7)
);

$graph->SetDataType("text-data");  //Must be called before SetDataValues

$graph->SetDataValues($example_data);
$graph->SetYTickIncrement(2);  //a smaller graph now - so we set a new tick increment

$graph->SetXLabelAngle(90);
$graph->SetXTitle("");
$graph->SetYTitle("Price");
$graph->SetPlotType("lines");
$graph->SetLineWidth(1);

$graph->SetNewPlotAreaPixels(70,10,375,100);  // where do we want the graph to go
$graph->DrawGraph(); // remember, since we said not to draw yet, PHPlot
                     // still needs a PrintImage command to write an image.


//Now do the second chart on the same image
unset($example_data);  //we are re-using $example_data (to save memory), but you don't have to
$example_data = array(
     array('a',30,40,20),
     array('b',50,'',10),  // here we have a missing data point, that's ok
     array('c',70,20,60),
     array('d',80,10,40),
     array('e',20,40,60),
     array('f',60,40,50),
     array('g',70,20,30)
);

$graph->SetDataType("text-data");  //Must be called before SetDataValues

$graph->SetDataValues($example_data);

$graph->SetXTitle("");
$graph->SetYTitle("Verbal Cues");
$graph->SetYTickIncrement(10);
$graph->SetPlotType("bars");
$graph->SetXLabelAngle(0);  //have to re-set as defined above

$graph->SetNewPlotAreaPixels(70,120,375,220);
$graph->SetPlotAreaWorld(0,0,7,80);
$graph->DrawGraph();

//Print the image
$graph->PrintImage();
?>

Relacionados:
Gerar Gráficos usando PHPLot.

Espero ter ajudado.
José Luiz Neto.

Facebook

About JLNeto