コード例 #1
0
ファイル: tickanchor.php プロジェクト: myfarms/PHPlot
# Printing helper
function prif($name, &$var, $before = '')
{
    return "{$before} {$name}=" . (isset($var) ? $var : "n/a");
}
# Auto title:
$title = 'X/Y Tick Anchors' . (empty($subtitle) ? "\n" : " - {$subtitle}\n") . prif('X tick anchor', $x_tick_anchor) . prif('Y tick anchor', $y_tick_anchor, ',') . prif('X tick inc.', $x_tick_step, ',') . prif('Y tick inc.', $y_tick_step, ',');
$data = array();
for ($x = $start; $x <= $stop; $x += $delta) {
    $data[] = array('', $x, $x);
}
$plot = new PHPlot(800, 600);
$plot->SetTitle($title);
$plot->SetPlotType('lines');
$plot->SetDataType('data-data');
$plot->SetDataValues($data);
$plot->SetDrawXGrid(True);
$plot->SetDrawYGrid(True);
if (isset($x_tick_step)) {
    $plot->SetXTickIncrement($x_tick_step);
}
if (isset($y_tick_step)) {
    $plot->SetYTickIncrement($y_tick_step);
}
if (isset($x_tick_anchor)) {
    $plot->SetXTickAnchor($x_tick_anchor);
}
if (isset($y_tick_anchor)) {
    $plot->SetYTickAnchor($y_tick_anchor);
}
$plot->DrawGraph();
コード例 #2
0
ファイル: range-log.php プロジェクト: myfarms/PHPlot
    $tp = array();
}
$tp = array_merge(array('c' => 10, 't' => 1, 'ar' => FALSE), $tp);
require_once 'phplot.php';
# Extract all test parameters as local variables:
extract($tp);
$title = "Log/Log Axis Test\nPlotting: XY = {$c}\n" . "Tick step: " . (empty($t) ? "Auto" : $t) . ", " . "Range: " . ($ar ? "Auto" : "Manually set");
# Plot X*Y=C
$data = array();
for ($x = 1; $x <= $c; $x++) {
    $data[] = array('', $x, $c / $x);
}
$p = new PHPlot(800, 600);
$p->SetDataType('data-data');
$p->SetDataValues($data);
$p->SetTitle($title);
$p->SetXScaleType('log');
$p->SetYScaleType('log');
if (empty($t)) {
    $p->SetXTickIncrement($t);
    $p->SetYTickIncrement($t);
}
if (!$ar) {
    $p->SetPlotAreaWorld(0, 1, $c + 1, $c + 1);
}
$p->SetXTickAnchor(0);
$p->SetYTickAnchor(0);
$p->SetDrawXGrid(True);
$p->SetDrawYGrid(True);
$p->SetPlotType('lines');
$p->DrawGraph();
コード例 #3
0
ファイル: ex-boxplot1.php プロジェクト: myfarms/PHPlot
{
    $n = count($row);
    $p = $k * ($n - 1);
    if ($p == (int) $p) {
        return $row[$p];
    }
    return ($row[(int) $p] + $row[(int) ($p + 1)]) / 2;
}
# Convert the experimental results to a PHPlot data array.
function reduce_data($results)
{
    $data = array();
    foreach ($results as $label => $row) {
        $n_samples = count($row);
        sort($row);
        $data[] = array("{$label}\n({$n_samples} Samples)", $row[0], kpercentile($row, 0.25), kpercentile($row, 0.5), kpercentile($row, 0.75), $row[$n_samples - 1]);
        // Maximum
    }
    return $data;
}
$plot = new PHPlot(800, 600);
$plot->SetTitle('Box Plot (without outliers)');
$plot->SetDataType('text-data');
$plot->SetDataValues(reduce_data($results));
$plot->SetPlotType('boxes');
# These 2 lines make tick marks line up with text-data data points:
$plot->SetXTickIncrement(1);
$plot->SetXTickAnchor(0.5);
$plot->SetImageBorderType('plain');
// Improves presentation in the manual
$plot->DrawGraph();
コード例 #4
0
ファイル: range-datex.php プロジェクト: myfarms/PHPlot
    $range = "{$xmin} : {$xmax}";
}
$title = "Date/time X Auto-Range Test: [{$range}]";
if (isset($mintick)) {
    $title .= "\nX Min Ticks = {$mintick}";
}
if (isset($xtickinc)) {
    $title .= "\nX Tick Increment = {$xtickinc}";
}
if (isset($tickanchor)) {
    $title .= "\nX Tick Anchor = {$tickanchor}";
}
$p = new PHPlot(800, 800);
$p->SetTitle($title);
$p->SetDataType('data-data');
$p->SetDataValues($data);
$p->SetXDataLabelPos('none');
$p->SetPlotType('lines');
# Format labels as date/time:
$p->SetXLabelType('time', $dtformat);
$p->SetXLabelAngle(90);
if (isset($mintick)) {
    $p->TuneXAutoTicks($mintick);
}
if (isset($tickanchor)) {
    $p->SetXTickAnchor($tickanchor);
}
if (isset($xtickinc)) {
    $p->SetXTickIncrement($xtickinc);
}
$p->DrawGraph();
コード例 #5
0
ファイル: ticksatdata.php プロジェクト: myfarms/PHPlot
<?php

# $Id$
# Testing phplot - Tick marks at data points (requires phplot >= 5.4.0)
require_once 'phplot.php';
$data = array();
for ($i = 0; $i < 20; $i++) {
    $data[] = array("Pt:{$i}", $i * $i);
}
$p = new PHPlot(800, 600);
$p->SetTitle('X Tick Mark and Data Label Alignment');
$p->SetDataType('text-data');
$p->SetDataValues($data);
$p->SetPlotType('lines');
$p->SetXTickIncrement(1);
$p->SetXTickAnchor(0.5);
$p->SetDrawXGrid(True);
$p->SetPlotAreaWorld(0.5);
$p->DrawGraph();