예제 #1
0
파일: u.pmarg.php 프로젝트: myfarms/PHPlot
function pmarg_test($call_SetMarginsPixels, $args_SetMarginsPixels, $call_SetPlotAreaPixels, $args_SetPlotAreaPixels, $return_margins)
{
    global $data, $margins_override, $plotarea_override;
    $p = new PHPlot_pv(PLOT_WIDTH, PLOT_HEIGHT);
    $p->SetTitle("Unused Title Goes Here");
    $p->SetDataType('data-data');
    $p->SetDataValues($data);
    $p->SetPlotType('lines');
    $p->SetXTickLabelPos('none');
    $p->SetXTickIncrement(1.0);
    $p->SetYTickIncrement(10.0);
    $p->SetYTickPos('both');
    $p->SetYTickLabelPos('both');
    $p->SetDrawXGrid(False);
    $p->SetDrawYGrid(False);
    $p->SetXTitle("Two Line\nX Axis Title");
    $p->SetYTitle("Three Line\nY Axis\nTitle");
    # Variant cases:
    if ($call_SetMarginsPixels) {
        call_user_func_array(array($p, 'SetMarginsPixels'), array_mask($margins_override, $args_SetMarginsPixels, 4));
    }
    if ($call_SetPlotAreaPixels) {
        call_user_func_array(array($p, 'SetPlotAreaPixels'), array_mask($plotarea_override, $args_SetPlotAreaPixels, 4));
    }
    # Produce but don't output the image. Comment out to test the test.
    $p->SetPrintImage(False);
    # Produce the graph:
    $p->DrawGraph();
    # Return the resulting margins or coordinates, as requested.
    $plot_area = $p->GET_plot_area();
    if ($return_margins) {
        return array($plot_area[0], PLOT_WIDTH - $plot_area[2], $plot_area[1], PLOT_HEIGHT - $plot_area[3]);
    }
    return $plot_area;
}
예제 #2
0
<?php

# $Id$
# Testing phplot - Default TT font (1a): No default path or font set, usettf
require_once 'phplot.php';
// Extend PHPlot class to allow access to protected variable(s):
class PHPlot_pv extends PHPlot
{
    public function GET_default_ttfont()
    {
        return $this->default_ttfont;
    }
}
$data = array(array('A', 3, 6), array('B', 2, 4), array('C', 1, 2));
$p = new PHPlot_pv(800, 800);
$p->SetDataType('text-data');
$p->SetDataValues($data);
$p->SetPlotType('bars');
$p->SetTitle('TTF default not set, SetUseTTF(true)');
$p->SetXTitle('X Axis Title');
$p->SetYTitle('Y Axis Title');
$p->SetUseTTF(True);
$p->DrawGraph();
fwrite(STDERR, "OK defaultfont1a: default_ttfont=" . $p->GET_default_ttfont() . "\n");
예제 #3
0
파일: colors.php 프로젝트: myfarms/PHPlot
{
    public function GET_rgb_array()
    {
        return $this->rgb_array;
    }
}
$p = new PHPlot_pv(800, 700);
# Use internal color map rgb_array to get a list of colors:
$colors = array_keys($p->GET_rgb_array());
sort($colors);
$nc = count($colors);
# Make a data array with 1 point, $nc data sets:
$dp = array('');
for ($i = 0; $i < $nc; $i++) {
    $dp[] = $nc - $i;
}
$data = array($dp);
$p->SetPlotType('bars');
$p->SetDataType('text-data');
$p->SetDataValues($data);
# Use all colors:
$p->SetDataColors($colors);
$p->SetShading(0);
# Make a legend with all the color names:
$p->SetLegend($colors);
$p->SetPlotAreaWorld(0.1, 0, NULL, NULL);
$p->SetTitle('PHPlot Default Color Map');
$p->SetXTickLabelPos('none');
$p->SetXTickPos('none');
$p->SetYTickIncrement(1);
$p->DrawGraph();
예제 #4
0
<?php

# $Id$
# Testing phplot - Default TT font (2a): Local path and default font.
# This test requires a specific font (see TEST_FONT) be present in the images/
# directory. The listed font is redistributable under the Open Fonts License.
require_once 'phplot.php';
define('TEST_FONT', 'FreeUniversal-Regular.ttf');
// Extend PHPlot class to allow access to protected variable(s):
class PHPlot_pv extends PHPlot
{
    public function GET_default_ttfont()
    {
        return $this->default_ttfont;
    }
}
$data = array(array('A', 3, 6), array('B', 2, 4), array('C', 1, 2));
$p = new PHPlot_pv(800, 800);
$p->SetDataType('text-data');
$p->SetDataValues($data);
$p->SetPlotType('bars');
$p->SetTitle('Local TTF path and default font');
$p->SetXTitle('X Axis Title');
$p->SetYTitle('Y Axis Title');
$p->SetTTFPath(getcwd() . DIRECTORY_SEPARATOR . 'images');
$p->SetDefaultTTFont(TEST_FONT);
$p->SetUseTTF(True);
$p->DrawGraph();
fwrite(STDERR, "OK defaultfont2a: default_ttfont=" . $p->GET_default_ttfont() . "\n");
예제 #5
0
# Number of points per line.
$data = array();
for ($x = 0; $x < $ppl; $x++) {
    $row = array('', $x);
    $offset = $n_shapes + $ppl - $x - 2;
    for ($j = 0; $j < $n_shapes; $j++) {
        $row[] = $offset - $j;
    }
    $data[] = $row;
}
$plot->SetImageBorderType('plain');
$plot->SetPlotType('linepoints');
$plot->SetDataType('data-data');
$plot->SetDataValues($data);
# Main plot title:
$plot->SetTitle("Linepoints Plot - Showing {$n_shapes} Point Shapes\n{$title_suffix}");
# Increase X range to make room for the legend.
$plot->SetPlotAreaWorld(0, 0, $ppl, $n_shapes + $ppl - 2);
# Turn off tick labels and ticks - not used for this plot.
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
$plot->SetYTickLabelPos('none');
$plot->SetYTickPos('none');
# Need some different colors;
$plot->SetDataColors($colors);
# If not showing default shapes, show all shapes:
if (!isset($use_default_shapes)) {
    $plot->SetPointShapes($shapes);
}
# Make the points bigger so we can see them:
$plot->SetPointSizes(10);