Menu

add y data labels

muppet77
2012-01-28
2012-09-07
  • muppet77

    muppet77 - 2012-01-28

    i am struggling to add y axis labels to a line graph.

    so far i have

    $legend_text = array('All', '0-2d', '2-4d', '4-7d', '7-16d');

    $plot = new PHPlot(800, 600);

    $plot->SetImageBorderType('plain'); // Improves presentation in the manual

    $plot->SetTitle("Llanbedr, West Wales GFS snow index");

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

    $plot->SetDataValues(read_prices_text_data(DATAFILE));

    $plot->SetPlotType('linepoints');

    $plot->SetDataColors(array('red', 'green', 'blue', 'black', 'orange'));

    $plot->SetLegend($legend_text);

    $plot->SetLegendWorld(0.1, 22);

    $plot->SetXLabelAngle(90);

    $plot->SetXTickPos('none');

    $plot->SetPlotAreaWorld(NULL, 0, NULL, 100);

    $plot->SetLineStyles('solid');

    $plot->SetLineWidths(2);

    $plot->DrawGraph();

    and have tried adding

    $plot->SetYDataLabelPos('plotin');

    with no luck.

    any ideas?

     
  • muppet77

    muppet77 - 2012-01-28

    by the way the graph plots fine apart from the y axis labels.

     
  • lbayuk

    lbayuk - 2012-01-28

    When I tried your script (without SetYDataLabelPos, and with a made-up data
    array), I get Y axis labels from 0 to 100 in steps of 10. This is the default
    behavior. What do you expect to see, and what exactly are you seeing? (I know
    this is dumb, but we are talking about the labels along the vertical axis,
    right?)

     
  • muppet77

    muppet77 - 2012-01-29

    I actually meant the y data labels next to the data points on the graph
    itself.

    how do I add those?

     
  • lbayuk

    lbayuk - 2012-01-29

    OK, sorry I missed that, the title was correct ("Y data labels") but you
    mentioned Y axis labels so I thought you meant those.

    Yes, SetYDataLabelPos('plotin') will turn on the "Y data value labels", which
    labels each data point within the plot area. This was first implemented for
    lines, linepoints, and points plots in PHPlot-5.3.0 (released in December
    2010), so the first thing to check is that you are using PHPlot 5.3.0 or
    newer.

    There is an example of a linepoints plot with Y data value labels is in the
    manual
    (note
    this example also turns off Y axis labels and turns on data label lines, but
    you don't have to do that to make the Y data value labels work). You might
    want to copy and paste that from the manual and see if it works for you. If
    that still doesn't help, can you try to reduce your code to a stand-along
    script that I can run?

     
  • muppet77

    muppet77 - 2012-01-29

    BINGO!

    i upgraded to 5.6.0 and the plots work a treat!

    thanks for your help !

     
  • Robert

    Robert - 2012-02-09

    New to this forum so not sure how to initiate a question, also new to PHPlot
    but making good progress. What I am trying to do is to present Y data labels
    on top of my bars in a bar chart, BUT only for the latest of the three bars in
    each series, leaving the first two clear. At the moment I can only have all 3
    labels, using $plot->SetYDataLabelPos('plotin'); or none. Does anyone know of
    a way, please. Very grateful of any help.

     
  • lbayuk

    lbayuk - 2012-02-09

    FYI, on the top-level view of this discussion forum, at the bottom of the page
    under Add a Topic, is where you can start a new thread.

    I copied your post to a new thread here: https://sourceforge.net/projects/php
    lot/forums/forum/46382/topic/5009239
    to avoid confusion.

     

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.