本文整理汇总了PHP中Plot::getX方法的典型用法代码示例。如果您正苦于以下问题:PHP Plot::getX方法的具体用法?PHP Plot::getX怎么用?PHP Plot::getX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plot
的用法示例。
在下文中一共展示了Plot::getX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: plotSellmeier
public static function plotSellmeier()
{
$plot = new Plot();
$plot->title("N Vs. Wavelength");
$plot->xlabel("Wavelength (micrometers)");
$plot->ylabel("Index of Refraction");
$sell = new Sellmeier();
$sell->loadMaterialsData();
// Make material selection if it exists
if (isset($_GET['selection'])) {
// Parse selection
$selection = json_decode(urldecode($_GET['selection']));
// print_r($selection);
if (!$sell->selectMaterials($selection)) {
$errors[] = new UserError("Materials do not exist", 1);
}
// Parse legend
$legend = array();
if (isset($_GET['legend']) && is_array($_GET['legend']) && count($_GET['legend']) == count($selection)) {
$legend = $_GET['legend'];
} else {
foreach ($selection as $material => $array) {
foreach ($array as $key => $axis) {
$legend[] = $material . " (axis " . $axis . ")";
}
}
}
$plot->legend($legend);
// Parse title
if (isset($_GET['title'])) {
$title = $_GET['title'];
$sell->title($title);
}
// Parse domain
$xmin = 0.4;
$xmax = 1;
$step = 0.001;
if (isset($_GET['xmin']) && isset($_GET['xmax']) && isset($_GET['step'])) {
if (is_numeric($_GET['xmin']) && is_numeric($_GET['xmax']) && is_numeric($_GET['step'])) {
$xmin = $_GET['xmin'] + 0;
$xmax = $_GET['xmax'] + 0;
$step = $_GET['step'] + 0;
} else {
$errors[] = new UserError("Wavelength range must be a number", 1);
}
}
$plot->setX(range($xmin, $xmax, $step));
$ydata = array();
foreach ($sell->getSelection() as $name => $axis_array) {
foreach ($axis_array as $axis => $coeffs) {
$legend = $name . '.' . $axis;
$ydata[$legend] = array();
foreach ($plot->getX() as $x) {
$ydata[$legend][] = $sell->calcSellmeier($x, $coeffs['a'], $coeffs['b'], $coeffs['c'], $coeffs['d'], $coeffs['e']);
}
}
}
$plot->setY($ydata);
// Output plot data
echo $plot->getJson();
} else {
// Output materials list
echo $sell->getMaterialsJson();
}
}