title: Format long numbers for axis labels core plot
body: <p>I am trying to format long numbers in form of "k" for my axis labels. For example; if I have <strong>10000</strong>, I would like it to be displayed as <strong>10k</strong>.</p>
  
  <p>I have already tried to follow <a href="https://stackoverflow.com/a/4716523/437146">this</a> answer. But I could not manage to get formatted numbers. What I need to do additionally? Please guide me. Thanks.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p><strong>HumanReadableFormatter.h</strong></p>
  
  <pre><code>@interface HumanReadableFormatter : NSNumberFormatter
  
  @end
  </code></pre>
  
  <p><strong>HumanReadableFormatter.m</strong></p>
  
  <p>I have modified code from the link above to meet my requirements.</p>
  
  <pre><code>#import "HumanReadableFormatter.h"
  
  @implementation HumanReadableFormatter
  
  static const char sUnits[] = { '\0', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y' };
  static int sMaxUnits = sizeof sUnits - 1;
  
      -(NSString *) stringForObjectValue:(id)obj
  {
      int multiplier =  1000;
      int exponent = 0;
  
      double bytes = [(NSNumber *)obj doubleValue];
  
      while ((bytes &gt;= multiplier) &amp;&amp; (exponent &lt; sMaxUnits)) {
          bytes /= multiplier;
          exponent++;
      }
      return [NSString stringWithFormat:@"%@ %c", [super stringFromNumber: [NSNumber numberWithDouble: bytes]], sUnits[exponent]];
  
  }
  
  @end
  </code></pre>
  
  <p><strong>Graph Code:</strong></p>
  
  <pre><code>if(!rightY)
      rightY = [[CPTXYAxis alloc]init];
  rightY.labelingPolicy = CPTAxisLabelingPolicyAutomatic;
  rightY.orthogonalCoordinateDecimal = CPTDecimalFromFloat(totIntervalShown);
  rightY.axisConstraints = [CPTConstraints constraintWithUpperOffset:-40];
  rightY.coordinate = CPTCoordinateY;
  rightY.majorTickLength = 0;
  rightY.minorTickLength = 0;
  rightY.tickDirection = CPTSignNone;
  rightY.plotSpace  = barPlotSpace;
  
  NSNumberFormatter *numFormatter;
  if(lowerLock &lt; 1000) //if value is &lt; 1000, normally format it
  {
  numFormatter = [[NSNumberFormatter alloc] init];
  [numFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
  numFormatter.maximumFractionDigits = 2;
  numFormatter.minimumFractionDigits = 2;
  }
  else   //for &gt; 1000, format in human readable form
  {
      numFormatter = [[HumanReadableFormatter alloc] init];
  //what i need to do here more?
  }
  rightY.labelFormatter = numFormatter;
  
  //formatted as shown on right side on graph
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/aUDL0.png" alt="enter image description here"></p>
  
  <p><strong>Nested Loop:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/liRpo.png" alt="enter image description here"></p>