Menu

Choose when the X label will be displayed?

Guilherme
2013-06-05
2013-06-06
  • Guilherme

    Guilherme - 2013-06-05

    I'm plotting a graph with line and points. Above the point the value is printed,

    I want to not display the value of the data, when it's 0(zero). Did someone already have tried something like this?
    When I use the type line and the X axis doesn't have much space between each item the values inside the graph overlap themselves.

    You can take a look at http://imageshack.us/f/826/graficoe.png/

    Best Regards,
    Guilherme

     

    Last edit: Guilherme 2013-06-05
  • lbayuk

    lbayuk - 2013-06-05

    You can do this with a custom label formatting function. Define your function to return an empty string if you do not want that value labeled:

    function my_format($label)
    {
      if ($label == 0) return '';
      return $label;
    }
    

    Now tell PHPlot to use your function to format the Y data labels:

    $plot->SetYLabelType('custom', 'my_format');
    

    More about this here with a longer example here

     
  • Guilherme

    Guilherme - 2013-06-06

    Perfect man!
    Thank you!

     
  • lbayuk

    lbayuk - 2013-06-06

    Sorry, a correction: What I posted above, using SetYLabelType() will affect both Y tick labels (those on the axis), and Y data labels (those within the plot). The unwanted side effect would be no 0 label on the Y axis. I should have said to use this:

    $plot->SetYDataLabelType('custom', 'my_format');
    

    Which only applies to the Y data labels (inside the plot area).

     

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.