<?php include "../jpgraph.php"; include "../jpgraph_line.php"; $f = new FuncGenerator('cos($i)', '$i*$i*$i'); list($xdata, $ydata) = $f->E(-M_PI, M_PI, 25); $graph = new Graph(350, 430, "auto"); $graph->SetScale("linlin"); $graph->SetShadow(); $graph->img->SetMargin(50, 50, 60, 40); $graph->SetBox(true, 'black', 2); $graph->SetMarginColor('white'); $graph->SetColor('lightyellow'); $graph->SetAxisStyle(AXSTYLE_BOXIN); $graph->xgrid->Show(); //$graph->xaxis->SetLabelFormat('%.0f'); $graph->img->SetMargin(50, 50, 60, 40); $graph->title->Set("Function plot"); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->subtitle->Set("(BOXIN Axis style)"); $graph->subtitle->SetFont(FF_FONT1, FS_NORMAL); $lp1 = new LinePlot($ydata, $xdata); $lp1->SetColor("blue"); $lp1->SetWeight(2); $graph->Add($lp1); $graph->Stroke(); ?>
<?php include "../jpgraph.php"; include "../jpgraph_line.php"; include "../jpgraph_utils.inc.php"; $f = new FuncGenerator('cos($x)*$x'); list($xdata, $ydata) = $f->E(-1.2 * M_PI, 1.2 * M_PI); $f = new FuncGenerator('$x*$x'); list($x2data, $y2data) = $f->E(-2, 2); // Setup the basic graph $graph = new Graph(450, 350, "auto"); $graph->SetScale("linlin"); $graph->SetShadow(); $graph->img->SetMargin(50, 50, 60, 40); $graph->SetBox(true, 'black', 2); $graph->SetMarginColor('white'); $graph->SetColor('lightyellow'); // ... and titles $graph->title->Set('Example of Function plot'); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->subtitle->Set("(With some more advanced axis formatting\nHiding first and last label)"); $graph->subtitle->SetFont(FF_FONT1, FS_NORMAL); $graph->xgrid->Show(); $graph->yaxis->SetPos(0); $graph->yaxis->SetWeight(2); $graph->yaxis->HideZeroLabel(); $graph->yaxis->SetFont(FF_FONT1, FS_BOLD); $graph->yaxis->SetColor('black', 'darkblue'); $graph->yaxis->HideTicks(true, false); $graph->yaxis->HideFirstLastLabel(); $graph->xaxis->SetWeight(2);
<?php // content="text/plain; charset=utf-8" // // Basic example on how to use custom tickmark feature to have a label // at the start of each month. // require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_line.php'; require_once 'jpgraph/jpgraph_utils.inc.php'; // // Create some random data for the plot. We use the current time for the // first X-position // $f = new FuncGenerator('cos($x)+1.5*cos(2*$x)'); list($datax, $datay) = $f->E(0, 10); // Now get labels at 1/2 PI intervall $tickPositions = array(); $tickLabels = array(); $tickPositions[0] = 0; $tickLabels[0] = '0'; for ($i = 1; $i / 2 * M_PI < 11; ++$i) { $tickPositions[$i] = $i / 2 * M_PI; if ($i % 2) { $tickLabels[$i] = $i . '/2' . SymChar::Get('pi'); } else { $tickLabels[$i] = $i / 2 . SymChar::Get('pi'); } } $n = count($datax); $xmin = $datax[0];
private function fundamento($fundamento, $metodos) { switch ($fundamento) { case 'ecuacion_de_raices': $xinicio = $this->p_entrada[1][1]; $xfin = $this->p_entrada[2][1]; // END PARAMETROS $val = 0; for ($i = $xinicio; $i <= $xfin; $i += 0.1) { $this->xdata[$val] = $i; $this->ydata[$val] = $this->f($this->p_entrada[0][1], $i); $val++; } // Create the graph $g = new Graph(800, 600); $g->SetMargin(30, 20, 40, 30); $g->title->Set("Grafico de F(x)"); $g->subtitle->Set('(Puntos de intervalo en azul)'); $g->subtitle->SetColor('darkred'); $g->SetMarginColor('lightblue'); $g->SetScale('int'); // We want 1 decimal for the X-label $g->xaxis->SetLabelFormat('%1.0f'); $lplot = new LinePlot($this->ydata, $this->xdata); $g->Add($lplot); for ($i = 1; $i < count($this->tabla_resultados); $i++) { $pplot = new ScatterPlot(array($this->f($this->p_entrada[0][1], $this->tabla_resultados[$i][1]), $this->f($this->p_entrada[0][1], $this->tabla_resultados[$i][2])), array($this->tabla_resultados[$i][1], $this->tabla_resultados[$i][2])); $g->Add($pplot); $pplot->SetImpuls(); } $img = time() . 'test22gr.png'; $rutaImg = $this->cad->directorios(SAVE_IMAGEN . "/" . $this->p_nombre[0] . "/" . $this->p_nombre[1]) . "/" . $img; $g->Stroke($rutaImg); return $this->cad->union(LOAD_IMG . "/" . $this->p_nombre[0] . "/" . $this->p_nombre[1]) . "/" . $img; break; case 'ajuste_de_curvas': // Create the graph $g = new Graph(800, 600); $g->SetMargin(30, 20, 40, 30); $g->title->Set("Grafico de F(x)"); $g->subtitle->Set('(Puntos de intervalo en azul)'); $g->subtitle->SetColor('darkred'); $g->SetMarginColor('lightblue'); $g->SetScale('int'); // We want 1 decimal for the X-label $g->xaxis->SetLabelFormat('%1.0f'); $ecuacion = ""; for ($i = 1; $i < count($this->tabla_resultados); $i++) { $ecuacion .= "+" . $this->tabla_resultados[$i][3]; } $f = new FuncGenerator($this->add_dolar($ecuacion)); list($xdata, $ydata) = $f->E(0.1, 20); $lplot = new LinePlot($ydata, $xdata); $g->Add($lplot); $f2 = new FuncGenerator($this->add_dolar($this->p_entrada[0][1])); list($xdata, $ydata) = $f2->E(0.1, 20); $lplot = new LinePlot($ydata, $xdata); $g->Add($lplot); for ($i = 1; $i < count($this->tabla_resultados); $i++) { $pplot = new ScatterPlot(array($this->f($this->p_entrada[0][1], $this->p_entrada[$i + 1][1])), array($this->p_entrada[$i + 1][1])); $g->Add($pplot); $pplot->SetImpuls(); } $g->SetScale('lin', -4, 4); $img = time() . 'test22gr.png'; $rutaImg = $this->cad->directorios(SAVE_IMAGEN . "/" . $this->p_nombre[0] . "/" . $this->p_nombre[1]) . "/" . $img; $g->Stroke($rutaImg); return $this->cad->union(LOAD_IMG . "/" . $this->p_nombre[0] . "/" . $this->p_nombre[1]) . "/" . $img; break; default: # code... break; } }