This example shows the use of SetYTickAnchor to tell PHPlot that we want a tick mark and label at a specific value.
Example 5.37. Setting a Y Tick Anchor
First, here is the example without a Y tick anchor. Note that there is no Y tick mark or label at the X axis Y=0.
The script uses SetPlotAreaWorld to set the Y axis range
to -3.5 to 13.5. This is used here to illustrate the need for setting a Y
tick anchor, and the effect of setting the Y tick anchor at 0. Without
SetPlotAreaWorld(), PHPlot-6.0.0 and later (but not
older versions) will automatically calculate the Y range such that a tick
mark will be at Y=0 even without SetYTickAnchor(0).

<?php
# PHPlot Example: Using a Y tick anchor to force a tick at 0.
# This requires PHPlot >= 5.4.0
require_once 'phplot.php';
# The variable $set_anchor can be set to a value in another script
# which calls this script, to set the Y anchor to that value.
if (isset($set_anchor))
$case = "with Y tick anchor at $set_anchor";
else
$case = "without Y tick anchor";
# Function to plot:
function f($x)
{
if ($x == 0) return 0;
return 5 + 8 * sin(200 * M_PI / $x);
}
$data = array();
for ($x = 0; $x < 500; $x++)
$data[] = array('', $x, f($x));
$plot = new PHPlot(800, 600);
$plot->SetImageBorderType('plain'); // For presentation in the manual
$plot->SetTitle("Example $case");
$plot->SetDataType('data-data');
$plot->SetDataValues($data);
$plot->SetPlotType('lines');
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
# See notes in reference manual on this:
$plot->SetPlotAreaWorld(NULL, -3.5, NULL, 13.5);
if (isset($set_anchor))
$plot->SetYTickAnchor($set_anchor);
$plot->DrawGraph();
Using SetYTickAnchor(0) tells PHPlot to shift the Y tick marks and labels to place a tick mark at Y=0.

<?php # PHPlot Example: Using a Y tick anchor to force a tick at 0. # This sets a variable and calls the script directly above. $set_anchor = 0; require_once 'ytickanchor.php';
This version of the manual was produced for the
PHPlot Sourceforge project web service site, which requires the logo on each
page.
To download a logo-free copy of the manual, see the
PHPlot project downloads
area.