本文整理匯總了PHP中Plot::legend方法的典型用法代碼示例。如果您正苦於以下問題:PHP Plot::legend方法的具體用法?PHP Plot::legend怎麽用?PHP Plot::legend使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Plot
的用法示例。
在下文中一共展示了Plot::legend方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: plotSpectra
public static function plotSpectra()
{
$plot = new Plot();
$plot->xlabel("Wavelength (nm)");
$spectra = new Spectra();
$spectra->loadOptions();
// Make material selection if it exists
if (isset($_GET['selection'])) {
$selection = json_decode(urldecode($_GET['selection']));
// print_r($selection);
$x = array();
$y = array();
$legend = array();
foreach ($selection as $type => $name_array) {
$plot->ylabel($type . " (cm^2)");
foreach ($name_array as $name => $axis_array) {
$plot->title($name . " " . $type . " Vs. Wavelength");
$n = 0;
foreach ($axis_array as $axis => $range_array) {
// print_r($axis);
$legend[$n] = $axis . " axis";
$y[$legend[$n]] = array();
foreach ($range_array as $range => $empty) {
if (!$spectra->selectOptions($type, $name, $axis, $range)) {
$errors[] = new UserError("Options do not exist", 1);
}
if ($n == 0) {
// only need wavelengths once
$x = array_merge($x, $spectra->getWavelengths());
}
$y[$legend[$n]] = array_merge($y[$legend[$n]], $spectra->getSignals());
$spectra->clearSelection();
}
$n = $n + 1;
}
}
}
$plot->setX($x);
$plot->setY($y);
$plot->legend($legend);
// Output plot data
echo $plot->getJson();
} else {
// Output materials list
echo $spectra->getJson();
}
}