16/09/2010, 08:12
|
| | | Fecha de Ingreso: septiembre-2009
Mensajes: 88
Antigüedad: 15 años, 1 mes Puntos: 2 | |
Respuesta: jpgraph Curvas y Barras Hola Lair, te agradezco mucho tu respuesta, pero la idea del Grafico en con curvas como las que nos muestra http://doc.async.com.br/jpgraph/html...splineex1.html esta es la que usa interpolaciones.
Mira haciendo pruebas llegue a esto pero todavia me falta dejar bien alineadas la barras. Código PHP: <?php
include "jpgraph.php";
include "jpgraph_line.php";
include "jpgraph_scatter.php";
include "jpgraph_regstat.php";
include ( "jpgraph_bar.php" );
// Original data points
$xdata = array(195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211);
$ydata = array(0,0,0,0,0,0,0.0001,0.0044,0.0540,0.2420, 0.3989, 0.2420,0.0540, 0.0044,0.0001,0,0 );
// Get the interpolated values by creating
// a new Spline object.
$spline = new Spline($xdata,$ydata);
// For the new data set we want 40 points to
// get a smooth curve.
list($newx,$newy) = $spline->Get(100);
$linea=0;
$ynew= array();
foreach ($newx as $key => $value) {
// echo "Clave: $key; Valor: $value<br />\n";
if(floor($value) == @$xdata[$linea])
{
$ynew[$key]= $ydata[$linea];
$linea++;
}
else
{
$ynew[$key]='';
}
}
// Create the graph
$g = new Graph(500,400);
$g->SetMargin(30,20,40,30);
$g->title->Set("Natural cubic splines");
$g->title->SetFont(FF_ARIAL,FS_NORMAL,12);
$g->subtitle->Set('(Control points shown in red)');
$g->subtitle->SetColor('darkred');
$g->SetMarginColor('lightblue');
$g->img->SetImgFormat('jpeg');
// Create a bar pot
$bplot = new BarPlot ($ynew,$newx);
$bplot -> SetFillColor ( "orange" );
//$g->img->SetAntiAliasing();
// We need a linlin scale since we provide both
// x and y coordinates for the data points.
$g->SetScale('linlin');
// We want 1 decimal for the X-label
//$g->xaxis->SetLabelFormat('%1.1f');
//$g -> xaxis -> SetTickLabels ( $newx );
// We use a scatterplot to illustrate the original
// contro points.
$splot = new ScatterPlot($ydata,$xdata);
//
$splot->mark->SetFillColor('[email protected]');
$splot->mark->SetColor('[email protected]');
// And a line plot to stroke the smooth curve we got
// from the original control points
$lplot = new LinePlot($newy,$newx);
$lplot->SetColor('navy');
// Add the plots to the graph and stroke
$g->Add($bplot);
$g->Add($lplot);
$g->Add($splot);
$g->Stroke();
?> Espero me puedas ayudar.
__________________ Sé fiel hasta la muerte, y yo te daré la corona de la vida.
Ap. 2:10 |