Menu

Y axis values repeated

laura
2010-04-07
2012-09-07
  • laura

    laura - 2010-04-07

    Hi,

    I have a problem with some plots because the Y axis values are repeated.

    This is my source code:

    $plot = new PHPlot(800, 600);

    $data = array(array('',25,3.61,""),array('',25,"",4.41),array('',30,4.43,""),

    array('',30,"",4.40),array('',35,4.41,""),array('',35,"",4.41));

    $plot->SetDataType('data-data');

    $plot->SetDataValues($data);

    //Set titles

    $plot->SetTitle("Example");

    $plot->SetXTitle('x axis');

    $plot->SetYTitle('y axis');

    $plot->SetImageBorderType('plain');

    // Set the backgrounds

    $plot ->SetDrawPlotAreaBackground(1);

    $plot ->SetBackgroundColor("white");

    //Define the plot option

    $plot->SetPlotType('lines');

    //No 3-D shading of the bars:

    $plot->SetShading(0);

    //Line width

    $plot->SetLineWidths(1);

    //Turn off X tick labels and ticks because they don't apply here:

    $plot->SetXTickPos('none');

    // Format the Y Data Labels as numbers with 1 decimal place.

    // Note that this automatically calls SetYLabelType('data').

    $plot->SetPrecisionY(0);

    $plot->SetXDataLabelPos('none');

    $plot->SetXLabelType('data');

    $plot->SetPrecisionX(0);

    $plot->DrawGraph();

    I can't put decimal values in the Y axis, because of that
    $plot->SetPrecisionY(0), if I take off this instruction is working properly.
    How can I do for not having the integers repeated? It's not always happening,
    it depends on the data.

    Many thanks in advance!

     
  • lbayuk

    lbayuk - 2010-04-07

    I think you will have to do one or more of these things:

    1. Let the Y axis display decimals with e.g. SetPrecision(2). But you said you can't do this, although I'm not sure why.

    2. Set a specific Y axis range with SetPlotAreaWorld(NULL, $ymin, NULL, $ymax) instead of letting PHPlot calculate it based on your data. You would pick a wider range.

    3. Set either the Y tick increment (SetYTickIncrement(1)), or number of Y tick marks (SetNumYTicks(2)). This reduces the number of tick marks and labels on the Y axis, so they get labeled 3, 4, and 5.

     

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.