Changeset 872 for trunk


Ignore:
Timestamp:
Nov 22, 2009, 6:06:04 PM (12 years ago)
Author:
Jari Häkkinen
Message:

Addresses #403. Better looking y and x axis values.

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Graph.cc

    r863 r872  
    2121
    2222#include "Graph.h"
     23
     24#include <cmath>
    2325
    2426namespace theplu {
     
    6466      pls_.scol0a(2,0,0,0,1.0);
    6567      pls_.col0(2);
    66       pls_.box("bcnstv", 10, 1, "bcnstv", yrange_/5, 1);
     68      unsigned int ytickspacing=tick_spacing(yrange_);
     69      unsigned int xtickspacing=tick_spacing(x.size());
     70      pls_.box("bcnstv", xtickspacing, 1, "bcnstv", ytickspacing, 1);
    6771      pls_.col0(1);
    6872    }
     
    7276      pls_.join(i-1,x[i],i,x[i]);
    7377    }
     78  }
     79
     80
     81  unsigned int Graph::tick_spacing(const double range) const
     82  {
     83    double frac=range/5;
     84    unsigned char characteristic=log10(frac);
     85    unsigned int power=pow(10,characteristic);
     86    unsigned char msn=frac/power;
     87    return power*msn;
    7488  }
    7589
  • trunk/lib/Graph.h

    r863 r872  
    7373
    7474  private:
     75    unsigned int tick_spacing(const double range) const;
     76
    7577    unsigned int plots_; // keep track of number of plots drawn
    7678    plstream pls_;
Note: See TracChangeset for help on using the changeset viewer.