title: Core Plot : X Axis Labels don't appear the first time the graph is drawn
body: <p>Am trying to draw some graphs in an iPhone App using Core Plot. Here is one such graph from the App :</p>
  
  <p><img src="https://i.stack.imgur.com/SVnn7.png" alt="enter image description here"></p>
  
  <p>As you can see, the X Axis labels are just showing 1,2,3... labels, whereas I have configured the corresponding date to be displayed in them. This graph re-draws every few minutes. When it re-draws, it displays the x-axis labels (i.e. the date values) correctly, as seen below :</p>
  
  <p><img src="https://i.stack.imgur.com/2Lpa9.png" alt="enter image description here"></p>
  
  <p>Whereas the first time, it just shows 1,2,3....</p>
  
  <p>How am I setting the X Axis Labels?</p>
  
  <p>I am doing it in 'numberOfRecordsForPlot', not when setting all other parameters (like color, padding, etc) for the graph. This is because I get the values for plotting only after I have set the colors, etc for the graph, &amp; so in numberOfRecordsForPlot(), I calculate the axis ranges for both the axes (depending on the values that come in every few minutes) and also calculate the custom tick locations &amp; the x-axis labels &amp; set it there. Here's the code snippet :</p>
  
  <pre><code>-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot {
  ...
  ...
  
  NSArray *customTickLocations = [NSArray arrayWithObjects :
                                  [NSDecimalNumber numberWithInt:0],
                                  [NSDecimalNumber numberWithInt:1],
                                  [NSDecimalNumber numberWithInt:2],
                                  [NSDecimalNumber numberWithInt:3],
                                  [NSDecimalNumber numberWithInt:4],
                                  nil];
  // assume that we are plotting 5 points at a time
  NSMutableArray *xAxisLabels = [[NSMutableArray alloc] init];
  for (int i=0; i&lt;self.arrayKeys.count ; i++) {
  
      NSString *myData = [dict objectForKey:[self.arrayKeys objectAtIndex:i]];
      if ((myData == nil) || (myData == NULL)) {
          NSLog(@"WARN : Invalid data");
          continue;
      }
      NSDate *date = (NSDate *) [self.arrayKeys objectAtIndex:i];
      [xAxisLabels addObject:date];
  }
  NSUInteger labelLocation = 0;
  NSMutableArray *customLabels = [NSMutableArray arrayWithCapacity:xAxisLabels.count];
  CPTMutableTextStyle *textStyle = [[CPTMutableTextStyle alloc] init];
  textStyle.fontSize = 10.0;
  textStyle.color = [CPTColor darkGrayColor];
  for (int i=0 ; i&lt;dictHealth.count ; i++) {
      NSNumber *tickLocation = [customTickLocations objectAtIndex:i];
      NSDateComponents *dateComponents = [self getComponentFromDate:
                                          (NSDate *)[xAxisLabels objectAtIndex:labelLocation++]];
      CPTAxisLabel *newLabel = [[CPTAxisLabel alloc]
                                initWithText:[NSString stringWithFormat:@"%d-%d-%d\n%d:%d:%d",
                                              dateComponents.year, dateComponents.month, dateComponents.day,
                                              dateComponents.hour, dateComponents.minute, dateComponents.second]
                                textStyle:textStyle];
      newLabel.tickLocation = [tickLocation decimalValue];
      newLabel.offset = 7.5;
      newLabel.rotation = M_PI/3;
      [customLabels addObject:newLabel];
  }
  axisSet.xAxis.axisLabels =  [NSSet setWithArray:customLabels];
  
  ...
  ...
  }
  </code></pre>
  
  <p>Can someone please help?</p>