- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试构建组合的散点图和折线图。目前散点图很好,当我添加线条时,它们向右旋转了 90 度,因此它们是垂直的而不是水平的。我一辈子都弄不明白为什么,所以如果有人有任何建议,那就太棒了。
下面的代码是完整的函数,忽略它的名称 - 现在不是样条图表(我真的应该改变它)。
function cg_graphs_spline_plot($surgeonname, $plotpoint, $nnotnullsingletotal, $surgeonplots, $baseline, $gsettings){
/*Build the binomial curve plots*/
$binomloop = $gsettings['maxmin'][0]['Max'] + 1;
for($i = 1; $i <= $binomloop; $i++){
$upperalert = cg_graphs_get_binomial($baseline, $i, 0.995);
$loweralert = cg_graphs_get_binomial($baseline, $i, 0.005);
$Ualert[] = ($upperalert['upper'] * 100);
$Lalert[] = ($loweralert['lower'] * 100);
//$upperalarm = cg_graphs_get_binomial($baseline, $i, 0.9995);
//$loweralarm = cg_graphs_get_binomial($baseline, $i, 0.0005);
//$Ualarm[] = ($upperalarm['upper'] * 100);
//$Lalarm[] = ($loweralarm['lower'] * 100);
}
unset($Ualert[0]); //delete the leading 0 value
unset($Lalert[0]); //delete the leading 0 value
mmi_watchdog('plotting alarm upper', '', $Ualert);
mmi_watchdog('plotting alarm lower', '', $Lalert);
//mmi_watchdog('plotting alarm upper', '', $Ualarm);
//mmi_watchdog('plotting alarm lower', '', $Lalarm);
/* Create the pData object */
$myData = new pData();
$myData->addPoints(array($plotpoint), "preSurgeons"); //Y pos just has to match pos of X
$myData->addPoints(array($nnotnullsingletotal), "pSurgeon"); //array pos matches, so the
foreach($surgeonplots['ops'] as $op){
$myData->addPoints($op, "Surgeons");
}
foreach($surgeonplots['reop'] as $reop){
$baselineplots[] = $baseline;
$myData->addPoints($reop, "reSurgeons");
}
$myData->addPoints($baselineplots, "baseline"); //add baseline for line graph
/** plot binomials */
$myData->addPoints($Ualert, "Ualert"); //add upper alert
$myData->addPoints($Lalert, "Lalert"); //add lower alert
//$myData->addPoints($Ualarm, "Ualarm"); //add upper alarm
//$myData->addPoints($Lalarm, "Lalarm"); //add lower alarm
/* Create the X axis and the binded series */
$myData->setSerieOnAxis("Surgeons",0);
$myData->setSerieOnAxis("pSurgeon",0);
$myData->setSerieOnAxis("Ualert",0);
$myData->setSerieOnAxis("Lalert",0);
$myData->setSerieOnAxis("baseline",0);
$myData->setAxisName(0,$gsettings['axisXlabel']); //Number of operations -- removed for now
$myData->setAxisXY(0,AXIS_X);
$myData->setAxisPosition(0,AXIS_POSITION_BOTTOM);
/* Create the Y axis and the binded series */
$myData->setSerieOnAxis("reSurgeons",1);
$myData->setSerieOnAxis("preSurgeons",1);
$myData->setAxisName(1,$gsettings['axisYlabel']);
$myData->setAxisXY(1,AXIS_Y);
$myData->setAxisUnit(1,"%");
$myData->setAxisPosition(1,AXIS_POSITION_LEFT);
/* Create All surgeons scatter chart binding */
$myData->setScatterSerie("Surgeons","reSurgeons",0);
$myData->setScatterSerieDescription(0,"All Surgeons");
$myData->setScatterSerieColor(0,array("R"=>255,"G"=>69,"B"=>0));
/* Create Single Surgions scatter point */
$myData->setScatterSerie("pSurgeon","preSurgeons",1);
$myData->setScatterSerieDescription(1, $surgeonname);
$myData->setScatterSerieColor(1,array("R"=>0,"G"=>191,"B"=>255));
/*unset the baseline for the first set*/
$myData->setSerieDrawable (array("baseline", "Ualert", "Lalert", "Ualarm", "Lalarm"), FALSE);
/* Create the pChart object */
$myPicture = new pImage(847,304,$myData);
$myPicture->drawGradientArea(0,0,847,304,DIRECTION_VERTICAL,array("StartR"=>47,"StartG"=>47,"StartB"=>47, "EndR"=>17,"EndG"=>17,"EndB"=>17,"Alpha"=>100));
$myPicture->drawGradientArea(0,250,847,304,DIRECTION_VERTICAL,array("StartR"=>47,"StartG"=>47,"StartB"=>47, "EndR"=>27,"EndG"=>27,"EndB"=>27,"Alpha"=>100));
$myPicture->drawLine(0,249,847,249,array("R"=>0,"G"=>0,"B"=>0));
$myPicture->drawLine(0,250,847,250,array("R"=>70,"G"=>70,"B"=>70));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName"=>drupal_get_path('module', 'cg_graphs')."/pChart/fonts/pf_arma_five.ttf","FontSize"=>6));
$myPicture->setFontProperties(array("R"=>255,"G"=>255,"B"=>255));
$myPicture->drawText(423,14,$gsettings['title'],array("R"=>255,"G"=>255,"B"=>255,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE));
/* Set the graph area */
$myPicture->setGraphArea(58,27,816,228);
/* Draw a rectangle */
$myPicture->drawFilledRectangle(57,27,816,228,array("R"=>0,"G"=>0,"B"=>0,"Dash"=>TRUE,"DashR"=>0, "DashG"=>51,"DashB"=>51,"BorderR"=>0,"BorderG"=>0,"BorderB"=>0));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>20));
/* Create the Scatter chart object */
$myScatter = new pScatter($myPicture,$myData);
/* Draw the scale */
$myScatter->drawScatterScale(array('LabelRotation' => 90, "Mode" => SCALE_MODE_MANUAL, "XMargin"=>4, "Pos" => SCALE_POS_LEFTRIGHT, "ManualScale" => $gsettings['maxmin'], 'Factors' => array(20)));
$myScatter->drawScatterLegend(640,266,array("Mode"=>LEGEND_VERTICAL ,"Style"=>LEGEND_NOBORDER, "Family"=>LEGEND_FAMILY_LINE));
/* Draw a scatter plot chart */
$myScatter->drawScatterPlotChart();
/*Draw Baseline chart*/
$myData->setSerieDrawable (array("pSurgeon", "Surgeons", "preSurgeons", "reSurgeons"), FALSE);
$myData->setSerieDrawable (array("baseline", "Ualert", "Lalert"), TRUE);
/* plot lines */
$myPicture->drawLineChart(array("DisplayValues"=>FALSE,"DisplayColor"=>DISPLAY_AUTO));
/* Write the 0 line */
$myPicture->drawThreshold(0,array("WriteCaption"=>TRUE));
/* Add a border to the picture */
$myPicture->drawRectangle(0,0,846,303,array("R"=>204,"G"=>204,"B"=>204));
$myData->setSerieDrawable (array("reSurgeons"), FALSE);
/* Set serie settings */
$myData->setSerieDescription("baseline","Average Baseline");
$myData->setSerieDescription("Ualert","Upper Alert Line");
$myData->setSerieDescription("Lalert","Lower Alert Line");
$myData->setSerieDescription("Ualarm","Upper Alarm Line");
$myData->setSerieDescription("Lalarm","Lower Alert Line");
$myPicture->drawLegend(540,266,array("Mode"=>LEGEND_VERTICAL ,"Style"=>LEGEND_NOBORDER, "Family"=>LEGEND_FAMILY_LINE));
/* Render the picture (choose the best way) */
$imagename = str_replace(' ', '-', $surgeonname);
$myPicture->render(drupal_get_path('module', 'cg_graphs')."/pChart/examples/pictures/".$imagename."-".$gsettings['name'].".png");
}
最佳答案
好吧,我想通了,我错过了线图的绘制比例。
新代码:
function cg_graphs_spline_plot($surgeonname, $plotpoint, $nnotnullsingletotal, $surgeonplots, $baseline, $gsettings){
/*Build the binomial curve plots*/
$binomloop = $gsettings['maxmin'][0]['Max'] + 1;
$x = 0;
for($i = 1; $i <= $binomloop; $i++){
$upperalert = cg_graphs_get_binomial($baseline, $i, 0.995);
$loweralert = cg_graphs_get_binomial($baseline, $i, 0.005);
$lineXaxis[] = $x; //build values for the line x axis
$baselineplots[] = $baseline; //build values for the baseline
$Ualert[] = ($upperalert['upper'] * 100);
$Lalert[] = ($upperalert['lower'] * 100);
$upperalarm = cg_graphs_get_binomial($baseline, $i, 0.9995);
$loweralarm = cg_graphs_get_binomial($baseline, $i, 0.0005);
$Ualarm[] = ($upperalarm['upper'] * 100);
$Lalarm[] = ($upperalarm['lower'] * 100);
$x++;
}
unset($Ualert[0]); //delete the leading 0 value
unset($Lalert[0]); //delete the leading 0 value
mmi_watchdog('plotting alarm upper', '', $Ualert);
mmi_watchdog('plotting alarm lower', '', $Lalert);
//mmi_watchdog('plotting alarm upper', '', $Ualarm);
//mmi_watchdog('plotting alarm lower', '', $Lalarm);
/* Create the pData object */
$myData = new pData();
$myData->addPoints(array($plotpoint), "preSurgeons"); //Y pos just has to match pos of X
$myData->addPoints(array($nnotnullsingletotal), "pSurgeon"); //array pos matches, so the
foreach($surgeonplots['ops'] as $op){
$myData->addPoints($op, "Surgeons");
}
foreach($surgeonplots['reop'] as $reop){
$myData->addPoints($reop, "reSurgeons");
}
$myData->addPoints($baselineplots, "baseline"); //add baseline for line graph
/** plot binomials */
$myData->addPoints($Ualert, "Ualert"); //add upper alert
$myData->addPoints($Lalert, "Lalert"); //add lower alert
$myData->addPoints($Ualarm, "Ualarm"); //add upper alarm
$myData->addPoints($Lalarm, "Lalarm"); //add lower alarm
/* Create the X axis and the binded series */
$myData->setSerieOnAxis("Surgeons",0);
$myData->setSerieOnAxis("pSurgeon",0);
$myData->setSerieOnAxis("Ualert",1);
$myData->setSerieOnAxis("Lalert",1);
$myData->setSerieOnAxis("baseline",1);
$myData->setAxisName(0,$gsettings['axisXlabel']); //Number of operations -- removed for now
$myData->setAxisXY(0,AXIS_X);
$myData->setAxisPosition(0,AXIS_POSITION_BOTTOM);
/* Create the Y axis and the binded series */
$myData->setSerieOnAxis("reSurgeons",1);
$myData->setSerieOnAxis("preSurgeons",1);
$myData->setAxisName(1,$gsettings['axisYlabel']);
$myData->setAxisXY(1,AXIS_Y);
$myData->setAxisUnit(1,"%");
$myData->setAxisPosition(1,AXIS_POSITION_LEFT);
/* Create All surgeons scatter chart binding */
$myData->setScatterSerie("Surgeons","reSurgeons",0);
$myData->setScatterSerieDescription(0,"All Surgeons");
$myData->setScatterSerieColor(0,array("R"=>255,"G"=>69,"B"=>0));
/* Create Single Surgions scatter point */
$myData->setScatterSerie("pSurgeon","preSurgeons",1);
$myData->setScatterSerieDescription(1, $surgeonname);
$myData->setScatterSerieColor(1,array("R"=>0,"G"=>191,"B"=>255));
/*unset the baseline for the first set*/
$myData->setSerieDrawable (array("baseline", "Ualert", "Lalert", "Ualarm", "Lalarm"), FALSE);
/* Create the pChart object */
$myPicture = new pImage(847,304,$myData);
$myPicture->drawGradientArea(0,0,847,304,DIRECTION_VERTICAL,array("StartR"=>47,"StartG"=>47,"StartB"=>47, "EndR"=>17,"EndG"=>17,"EndB"=>17,"Alpha"=>100));
$myPicture->drawGradientArea(0,250,847,304,DIRECTION_VERTICAL,array("StartR"=>47,"StartG"=>47,"StartB"=>47, "EndR"=>27,"EndG"=>27,"EndB"=>27,"Alpha"=>100));
$myPicture->drawLine(0,249,847,249,array("R"=>0,"G"=>0,"B"=>0));
$myPicture->drawLine(0,250,847,250,array("R"=>70,"G"=>70,"B"=>70));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName"=>drupal_get_path('module', 'cg_graphs')."/pChart/fonts/pf_arma_five.ttf","FontSize"=>6));
$myPicture->setFontProperties(array("R"=>255,"G"=>255,"B"=>255));
$myPicture->drawText(423,14,$gsettings['title'],array("R"=>255,"G"=>255,"B"=>255,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE));
/* Set the graph area */
$myPicture->setGraphArea(58,27,816,228);
/* Draw a rectangle */
$myPicture->drawFilledRectangle(57,27,816,228,array("R"=>0,"G"=>0,"B"=>0,"Dash"=>TRUE,"DashR"=>0, "DashG"=>51,"DashB"=>51,"BorderR"=>0,"BorderG"=>0,"BorderB"=>0));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>20));
/* Create the Scatter chart object */
$myScatter = new pScatter($myPicture,$myData);
/* Draw the scale */
$myScatter->drawScatterScale(array("Mode" => SCALE_MODE_MANUAL, "XMargin"=>4, "Pos" => SCALE_POS_LEFTRIGHT, "ManualScale" => $gsettings['maxmin'], 'Factors' => array(20)));
$myScatter->drawScatterLegend(640,266,array("Mode"=>LEGEND_VERTICAL ,"Style"=>LEGEND_NOBORDER, "Family"=>LEGEND_FAMILY_LINE));
/* Draw a scatter plot chart */
$myScatter->drawScatterPlotChart();
/*Draw Baseline chart*/
$myData->setSerieDrawable (array("pSurgeon", "Surgeons", "preSurgeons", "reSurgeons"), FALSE);
$myData->setSerieDrawable (array("baseline", "Ualert", "Lalert", "Ualarm", "Lalarm"), TRUE);
/* plot lines */
$myData->addPoints($lineXaxis,"Labels");
$myData->setSerieDescription("Labels","My labels");
$myData->setAbscissa("Labels");
$myPicture->drawScale(array("Mode" => SCALE_MODE_MANUAL, "XMargin"=>4, "Pos" => SCALE_POS_LEFTRIGHT, "ManualScale" => $gsettings['maxmin'], 'Factors' => array(20), 'RemoveXAxis' => TRUE));
$myPicture->drawLineChart(array("DisplayValues"=>FALSE,"DisplayColor"=>DISPLAY_AUTO));
/* Add a border to the picture */
$myPicture->drawRectangle(0,0,846,303,array("R"=>204,"G"=>204,"B"=>204));
/* Set serie settings */
$myData->setSerieDescription("baseline","Average Baseline");
$myData->setSerieDescription("Ualert","Upper Alert Line");
$myData->setSerieDescription("Lalert","Lower Alert Line");
$myData->setSerieDescription("Ualarm","Upper Alarm Line");
$myData->setSerieDescription("Lalarm","Lower Alert Line");
$myPicture->drawLegend(540,266,array("Mode"=>LEGEND_VERTICAL ,"Style"=>LEGEND_NOBORDER, "Family"=>LEGEND_FAMILY_LINE));
/* Render the picture (choose the best way) */
$imagename = str_replace(' ', '-', $surgeonname);
$myPicture->render(drupal_get_path('module', 'cg_graphs')."/pChart/examples/pictures/".$imagename."-".$gsettings['name'].".png");
}
关于php - Pchart - 错误轴上的折线图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16710037/
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
折线图是一种用于可视化数据变化趋势的图表,它可以用于表示任何数值随着时间或类别的变化。 折线图由折线段和折线交点组成,折线段表示数值随时间或类别的变化趋势,折线交点表示数据的转折点。 折
我是 d3 和 typescript 的新手。 我正在尝试使用 d3 v4 和 typescript 创建一个简单的折线图。 但是,我收到了一个 typescript 错误,如下图所示: 问题是什么?
我是 Qlikview 的新手,经过几次失败的尝试后,我不得不请求一些有关 Qlikview 中图表的指导。我想创建折线图,其中包含: 一维 - 一个月的时间段按天数分割 一个表达式 - 每天创建的任
我正在尝试使用 Firebase 实时数据库中的数据在 Android 中制作折线图。 这是数据库的结构: enter image description here 这是代码: public clas
我有一个 TSQL 查询,它提供了一些性能基线的一个月数据。我用折线图显示数据。现在我想在报告中添加更多参数,以提供从两个不同月份选择数据的选项,并将其显示在同一个折线图中以进行比较。我不知道如何开始
我有一个简单(但非常大)的数据集,其中包含从 4 月到 8 月在不同站点进行的计数。 在 4 月中旬和 7 月之间,没有零计数 - 但零线从最早到最晚的日期延伸。 以下是用于制作上述图表的部分数据(列
我正在创建一个折线图,我想在不改变线条长度的情况下增加线条的高度或厚度。 在增加宽度属性之前,它看起来像这样: 增加宽度属性后,它看起来像这样: 我只想增加 height,但是没有这样的属性,所以我尝
我想在折线图的顶部显示值。我看过this answer这很有帮助,但它改变了折线图节点。我想要的是相同的想法,但不在节点上显示值,而是在它们附近(可能在它们的右侧和上方)显示值,例如:
我正在尝试使用谷歌图表以折线图的形式显示mysql数据。我认为问题出在我尝试格式化谷歌图表数据的部分。我的代码有什么问题吗? $sth = mysql_query("SELECT * FROM rea
我有 JavaFX LineChart 和一些带有 XYChart.Series 对象的数据 XYChart.Series series = new XYChart.Series(); series.
给定: 理想图 - 描绘了我的机器应该具有的预期读数。实际图表 - 描述我的机器在该实例中的实际读数。 X轴:来自机器的力(N) Y 轴:时间 这两个图都是使用 python 中的 pyplot 库创
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 6 年前。
<% function table2(total,table_x,table_y,all_width,all_height,line_n
我想根据数据中的一列离散值过滤使用 plotly 创建的图表。最终目标是能够使用按钮来更新过滤值,所以我不想事先过滤数据。 library(plotly) df % filter(group1=
我正在尝试在 JavaFX 中创建折线图。此折线图应该有一个轴 (y) 与数字和另一个轴 (x) 与日期。日期范围应该由用户使用两个日期选择器来选择。现在这是我的问题:折线图只有类别和数字轴。有什么方
我正在使用 nivo 折线图,并希望将 x 轴用作时间线,最多一分钟。 不幸的是,我无法呈现该图表,因为它无法正确读取日期。例如,这是我的数据的一部分: { x: "2020-04-24T13:07:
我有一个用 gRaphael 创建的折线图。它有轴和刻度线,但我想要网格线。是否有内置的方法来实现这一点或可以帮助我的附加库? 最佳答案 gRaphael 没有添加网格线的内置方法,但绘制它们非常容易
我正在生成一份报告,该报告是根据查询字符串在网页的页面加载时生成的。我在电子表格中生成的单元格数据完全符合我的要求。现在我需要添加一个折线图。数据是动态的,行数会有所不同。 搜索后没有信息,这与在 .
我正在尝试使用 highcharts 中每 x 秒更新一次的折线图。理想情况下,我希望它使用一些特定数据进行初始化,并每 x 秒轮询一次 Web 服务,并进行相应更新。 目前,我只是尝试使用网络服务中
我是一名优秀的程序员,十分优秀!