Menu

Warning: imageline() expects parameter 5 to be integer, float given in /Library/WebServer/Documents/php/phplot-6.2.0/phplot.php on line 7798

2018-06-21
2018-06-25
  • P James Norris

    P James Norris - 2018-06-21

    I'm using phplot-6.2.0 on a MacBook Pro running OS 10.13.5 and PHP Version 7.2.0 and I'm getting the warning in the subjectline, and I'm not sure why. The code I'm running that is causing the problem is:

                $plot = new PHPlot(1375, 800);
                $plot->SetBackgroundColor('white');
                $plot->SetDataValues($array_lin);
                $plot->SetFailureImage(False); 
                $plot->SetFont('legend', 5);
                $plot->SetFont('title', 5);
                $plot->SetFont('x_label', 5);
                $plot->SetFont('y_label', 5);
                $plot->SetPlotType('thinbarline');
                $plot->SetPrintImage(False); 
                $plot->SetShading(0);
                $plot->SetTitle('Logarithmic Plot');
                $plot->SetTransparentColor('white');
                $plot->SetXDataLabelAngle(90);
                $plot->SetXLabelAngle(90);
                $plot->SetYDataLabelPos('both');
                $plot->SetYLabelType('data', 0);
                $plot->SetYScaleType('log');
                $plot->DrawGraph();
    
                echo '<img src="'.$plot->EncodeImage().'" alt="Plot Image">';
    

    $array_lin is a count($array_lin)>6,000 2D array, with floats for both elements. An example from the array is:

    $array_lin['3899']['0'] = ""
    $array_lin['3899']['1'] = 3
    $array_lin['3900']['0'] = 10500
    $array_lin['3900']['1'] = 1
    $array_lin['3901']['0'] = ""
    $array_lin['3901']['1'] = 4

    I'm getting 5093 of the warnings, but there are only 6091 of the $array_lin['#']['0'] = "" entries, so I don't see the connection.

    This code produces an image:

    And while I have y'all's attention, I was wondering if someone could epxlian why the image's y-axis has no ticks between 1 and 1001--I would have expcted ticks for 10-1000.

    Any help y'all can give me would be greatly appreciated.

    Thanks,
    James N

     
  • P James Norris

    P James Norris - 2018-06-21

    The image didn't seem to post, so here it is:

     
  • lbayuk

    lbayuk - 2018-06-22

    The message "expects integer, float given" is a little misleading. Normally the float given to imageline() is a whole number which gets silently converted to integer. In your case, mostly likely, the Y value is 0 or negative. For a log plot that gets you INF or NaN respectively, which cannot be converted to integer.

    Check your data. You probably have some Y <= 0.0. Can't do that with a log plot.

    As for tick marks, log plots have never been implemented that well. Very simple cases work OK but that's about it.

     
    • P James Norris

      P James Norris - 2018-06-25

      lbayuk,

      THANKS for the reply. I was able to get the log plot working based on your suggestion.

      The tick marks are still a problem. If I have some time--very unlikely anytime in the near future--maybe I'll dig into the phplot code and see if I fix this issue myself and then hand the fixed code over to y'all.

      Thanks again,
      James N

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.