Core plot Axes difficulty - core-plot

I am plotting Unix Timestamps vs weights, and so my x axis range, as an example, is:
1380330622 thru 1382696991
Y axis is: 83 thru 86 or so...
There are 40 entries.
My plot range is basically set up to the min<->max of each, and the graph data shows up fine... but I can't get my Axes to show up at all...
Initially the high x axis numbers were causing a huge number of major tick to be allocated, thats solved, but no axes:
-(void)configureAxis{
graph.plotAreaFrame.axisSet.borderLineStyle = [CPTLineStyle lineStyle];
// Line styles
CPTMutableLineStyle *axisLineStyle = [CPTMutableLineStyle lineStyle];
axisLineStyle.lineWidth = 3.0;
axisLineStyle.lineCap = kCGLineCapRound;
CPTMutableLineStyle *majorGridLineStyle = [CPTMutableLineStyle lineStyle];
majorGridLineStyle.lineWidth = 0.75;
majorGridLineStyle.lineColor = [CPTColor redColor];
CPTMutableLineStyle *minorGridLineStyle = [CPTMutableLineStyle lineStyle];
minorGridLineStyle.lineWidth = 0.25;
minorGridLineStyle.lineColor = [CPTColor blueColor];
// Text styles
CPTMutableTextStyle *axisTitleTextStyle = [CPTMutableTextStyle textStyle];
axisTitleTextStyle.fontName = #"Helvetica Bold";
axisTitleTextStyle.fontSize = 14.0;
// Axes
// Label x axis with a fixed interval policy
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
CPTXYAxis *x = axisSet.xAxis;
x.separateLayers = NO;
x.orthogonalCoordinateDecimal = CPTDecimalFromDouble(82.0f);
x.majorIntervalLength = CPTDecimalFromString(#"86400");
x.minorTicksPerInterval = 4;
x.tickDirection = CPTSignNone;
x.axisLineStyle = axisLineStyle;
x.majorTickLength = 12.0;
x.majorTickLineStyle = axisLineStyle;
x.majorGridLineStyle = majorGridLineStyle;
x.minorTickLength = 8.0;
x.minorGridLineStyle = minorGridLineStyle;
x.title = #"Date";
x.titleTextStyle = axisTitleTextStyle;
x.titleOffset = 25.0;
x.labelingPolicy = CPTAxisLabelingPolicyAutomatic;
// Label y axis with a fixed interval policy
CPTXYAxis *y = axisSet.yAxis;
y.separateLayers = NO;
y.orthogonalCoordinateDecimal = CPTDecimalFromDouble(1380340622.0f);
y.majorIntervalLength = CPTDecimalFromString(#"10");
y.minorTicksPerInterval = 4;
y.tickDirection = CPTSignNone;
y.axisLineStyle = axisLineStyle;
y.majorTickLength = 12.0;
y.majorTickLineStyle = axisLineStyle;
y.majorGridLineStyle = majorGridLineStyle;
y.minorTickLength = 8.0;
y.minorGridLineStyle = minorGridLineStyle;
y.title = #"Weight in kg";
y.titleTextStyle = axisTitleTextStyle;
y.titleOffset = 25.0;
y.labelingPolicy = CPTAxisLabelingPolicyAutomatic;
}
Here is the current output with numberforplot:
2013-10-26 11:13:04.509 app[2174:303] The size of the arays for x and y are: 41;41
2013-10-26 11:13:04.509 app[2174:303] XMIN: 111667.172778 XMAX: 112324.4975
2013-10-26 11:13:04.509 app[2174:303] YMIN: 83.225 YMAX: 85.701
2013-10-26 11:13:04.509 app[2174:303] Data dictionary: {
identifier = WEIGHT;
"max_x" = "112324.4975";
"max_y" = "85.701";
"min_x" = "111667.172778";
"min_y" = "83.225";
"x_values" = (
"111667.172778",
"111732.579167",
"111732.931944",
"111733.087222",
"111748.680278",
"111757.177778",
"111760.608056",
"111763.109444",
"111763.497222",
"111763.529167",
"111763.678056",
"111764.11",
"111772.890556",
"111773.146389",
"111779.491389",
"111785.4075",
"111796.832778",
"111821.3",
"111846.429722",
"111869.016389",
"111892.786389",
"111916.811111",
"111941.981944",
"111942.026389",
"111965.135833",
"111989.396667",
"112012.848611",
"112038.682778",
"112061.785",
"112085.694444",
"112109.053056",
"112131.653889",
"112157.381111",
"112181.126944",
"112205.423056",
"112205.711111",
"112229.128056",
"112252.898611",
"112276.948889",
"112300.449167",
"112324.4975"
);
"y_values" = (
"83.823",
"84.286",
"83.807",
"84.387",
"83.256",
"84.799",
"85.005",
"85.399",
"85.414",
"85.595",
"85.701",
"85.493",
"84.427",
"83.989",
"84.462",
"85.134",
"83.797",
"83.454",
"83.87",
"83.526",
"83.512",
"83.969",
"84.02",
"84.009",
"85.13",
"84.662",
"83.869",
"84.5",
"83.94",
"83.225",
"84.352",
"84.332",
"83.617",
"83.776",
"84.582",
"83.869",
"83.712",
"84.144",
"84.048",
"84.035",
"84.06"
);
}
2013-10-26 11:13:04.511 app[2174:303] Adding plot to graph system
2013-10-26 11:13:04.511 app[2174:303] Added... 1
2013-10-26 11:13:04.512 app[2174:303] Number of entries... 41
2013-10-26 11:13:04.512 app[2174:303] Number of entries... 41
2013-10-26 11:13:04.512 app[2174:303] 0,111667.172778
2013-10-26 11:13:04.513 app[2174:303] 1,111732.579167
2013-10-26 11:13:04.513 app[2174:303] 2,111732.931944
2013-10-26 11:13:04.513 app[2174:303] 3,111733.087222
2013-10-26 11:13:04.513 app[2174:303] 4,111748.680278
2013-10-26 11:13:04.513 app[2174:303] 5,111757.177778
2013-10-26 11:13:04.514 app[2174:303] 6,111760.608056
2013-10-26 11:13:04.514 app[2174:303] 7,111763.109444
2013-10-26 11:13:04.514 app[2174:303] 8,111763.497222
2013-10-26 11:13:04.514 app[2174:303] 9,111763.529167
2013-10-26 11:13:04.515 app[2174:303] 10,111763.678056
2013-10-26 11:13:04.515 app[2174:303] 11,111764.11
2013-10-26 11:13:04.515 app[2174:303] 12,111772.890556
2013-10-26 11:13:04.515 app[2174:303] 13,111773.146389
2013-10-26 11:13:04.515 app[2174:303] 14,111779.491389
2013-10-26 11:13:04.516 app[2174:303] 15,111785.4075
2013-10-26 11:13:04.516 app[2174:303] 16,111796.832778
2013-10-26 11:13:04.516 app[2174:303] 17,111821.3
2013-10-26 11:13:04.516 app[2174:303] 18,111846.429722
2013-10-26 11:13:04.516 app[2174:303] 19,111869.016389
2013-10-26 11:13:04.517 app[2174:303] 20,111892.786389
2013-10-26 11:13:04.517 app[2174:303] 21,111916.811111
2013-10-26 11:13:04.517 app[2174:303] 22,111941.981944
2013-10-26 11:13:04.517 app[2174:303] 23,111942.026389
2013-10-26 11:13:04.517 app[2174:303] 24,111965.135833
2013-10-26 11:13:04.518 app[2174:303] 25,111989.396667
2013-10-26 11:13:04.518 app[2174:303] 26,112012.848611
2013-10-26 11:13:04.518 app[2174:303] 27,112038.682778
2013-10-26 11:13:04.518 app[2174:303] 28,112061.785
2013-10-26 11:13:04.518 app[2174:303] 29,112085.694444
2013-10-26 11:13:04.518 app[2174:303] 30,112109.053056
2013-10-26 11:13:04.519 app[2174:303] 31,112131.653889
2013-10-26 11:13:04.519 app[2174:303] 32,112157.381111
2013-10-26 11:13:04.519 app[2174:303] 33,112181.126944
2013-10-26 11:13:04.519 app[2174:303] 34,112205.423056
2013-10-26 11:13:04.519 app[2174:303] 35,112205.711111
2013-10-26 11:13:04.520 app[2174:303] 36,112229.128056
2013-10-26 11:13:04.520 app[2174:303] 37,112252.898611
2013-10-26 11:13:04.520 app[2174:303] 38,112276.948889
2013-10-26 11:13:04.520 app[2174:303] 39,112300.449167
2013-10-26 11:13:04.520 app[2174:303] 40,112324.4975
2013-10-26 11:13:04.521 app[2174:303] Number of entries... 41
2013-10-26 11:13:04.521 app[2174:303] 0,83.823
2013-10-26 11:13:04.521 app[2174:303] 1,84.286
2013-10-26 11:13:04.522 app[2174:303] 2,83.807
2013-10-26 11:13:04.522 app[2174:303] 3,84.387
2013-10-26 11:13:04.522 app[2174:303] 4,83.256
2013-10-26 11:13:04.522 app[2174:303] 5,84.799
2013-10-26 11:13:04.522 app[2174:303] 6,85.005
2013-10-26 11:13:04.523 app[2174:303] 7,85.399
2013-10-26 11:13:04.523 app[2174:303] 8,85.414
2013-10-26 11:13:04.523 app[2174:303] 9,85.595
2013-10-26 11:13:04.523 app[2174:303] 10,85.701
2013-10-26 11:13:04.523 app[2174:303] 11,85.493
2013-10-26 11:13:04.524 app[2174:303] 12,84.427
2013-10-26 11:13:04.524 app[2174:303] 13,83.989
2013-10-26 11:13:04.524 app[2174:303] 14,84.462
2013-10-26 11:13:04.524 app[2174:303] 15,85.134
2013-10-26 11:13:04.524 app[2174:303] 16,83.797
2013-10-26 11:13:04.525 app[2174:303] 17,83.454
2013-10-26 11:13:04.525 app[2174:303] 18,83.87
2013-10-26 11:13:04.525 app[2174:303] 19,83.526
2013-10-26 11:13:04.525 app[2174:303] 20,83.512
2013-10-26 11:13:04.526 app[2174:303] 21,83.969
2013-10-26 11:13:04.526 app[2174:303] 22,84.02
2013-10-26 11:13:04.526 app[2174:303] 23,84.009
2013-10-26 11:13:04.526 app[2174:303] 24,85.13
2013-10-26 11:13:04.526 app[2174:303] 25,84.662
2013-10-26 11:13:04.526 app[2174:303] 26,83.869
2013-10-26 11:13:04.527 app[2174:303] 27,84.5
2013-10-26 11:13:04.527 app[2174:303] 28,83.94
2013-10-26 11:13:04.527 app[2174:303] 29,83.225
2013-10-26 11:13:04.527 app[2174:303] 30,84.352
2013-10-26 11:13:04.528 app[2174:303] 31,84.332
2013-10-26 11:13:04.528 app[2174:303] 32,83.617
2013-10-26 11:13:04.528 app[2174:303] 33,83.776
2013-10-26 11:13:04.528 app[2174:303] 34,84.582
2013-10-26 11:13:04.528 app[2174:303] 35,83.869
2013-10-26 11:13:04.529 app[2174:303] 36,83.712
2013-10-26 11:13:04.529 app[2174:303] 37,84.144
2013-10-26 11:13:04.529 app[2174:303] 38,84.048
2013-10-26 11:13:04.529 app[2174:303] 39,84.035
2013-10-26 11:13:04.529 app[2174:303] 40,84.06
2013-10-26 11:13:04.530 app[2174:303] Number of entries... 41

This is at least part of the problem: CPTDecimalFromDouble(1380340622.0f);
That number is too big to be represented exactly by a float value (forced by the "f" suffix). Unix time is an integer, so try something like this:
y.orthogonalCoordinateDecimal = CPTDecimalFromLong(1380330622);
Edit based on new information in the question:
Your axis locations are outside the range of the data. For example, the x-axis crosses the y-axis at y=82.0, but the plot range starts at 83.225.
x.orthogonalCoordinateDecimal = CPTDecimalFromDouble(y_min);
y.orthogonalCoordinateDecimal = CPTDecimalFromDouble(x_min);
If you always want to pin the axes to a certain spot in the plot area (e.g., one of the edges or the middle), regardless of the range of visible data, you can use axis constraints instead of the orthogonal coordinate.
x.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0];
y.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0];

Related

How can I edit the granularity of location data(lon, lat)

Lets say I have a location -44.1321, 50.3145 representing at a street level. What would the edited version be to represent it at a city level?
And also, what defines the granularity in the data? thanks.
The number of decimal places required for a particular precision for latitude & longitude at the equator is:
decimal places at equator
1.0 111.32 km
0.1 11.132 km
0.01 1.1132 km
0.001 111.32 m
0.0001 11.132 m
0.00001 1.1132 m
0.000001 111.32 mm
0.0000001 11.132 mm
0.00000001 1.1132 mm
As you moves away from the equator towards a pole the longitude distance decreases as it approaches the pole.
The longitude distance can be calculated by multiplying the latitude distance by the cosine of the longitude.
ie at 45degree 1.1132 m * cos(45)
= 0.00001* 0.707
= 0.7871 m

Core Plot - Bar plot automatic initial zooming

How do I set an initial zoom based the maximum value of the x-axis and y-axis?
Example:
Plot 1:
Maximum value:
x-axis = 100;
y-axis = 110;
Plot 2:
Maximum value:
x-axis = 180;
y-axis = 230;
I need to the initial zoom be equal to two plots.
Regards
This will adjust the plot space to fit the plot data for two plots:
[plotSpace scaleToFitPlots:#[plot1, plot2]];
You can use this shortcut to scale the plot space to fit all of the plots in a graph:
[plotSpace scaleToFitPlots:[graph allPlots]];

SpriteKit Gravity Acceleration

I have a scene with one physical body.
self.player.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:self.player.size.height / 2];
self.player.physicsBody.dynamic = YES;
self.player.physicsBody.allowsRotation = NO;
self.player.physicsBody.mass = 1;
[self addChild:self.player];
The gravity is set to be -9.8:
self.physicsWorld.gravity = CGVectorMake( 0.0, -9.8 );
I try to check if that's true:
-(void)update:(CFTimeInterval)currentTime {
/* Called before each frame is rendered */
double delta = currentTime - _pasttime;
_pasttime = currentTime;
float ax = (self.player.physicsBody.velocity.dx-self.oldVelocity.dx)/delta;
float ay = (self.player.physicsBody.velocity.dy-self.oldVelocity.dy)/delta;
self.oldVelocity = self.player.physicsBody.velocity;
NSLog(#"The acceleration is: %f %f",ax,ay);
}
And I get the following output:
2014-04-10 17:12:12.469 PhysicsTest[4508:60b] The acceleration is: 0.000000 -413.161133
2014-04-10 17:12:12.485 PhysicsTest[4508:60b] The acceleration is: 0.000000 -1732.006226
2014-04-10 17:12:12.502 PhysicsTest[4508:60b] The acceleration is: 0.000000 -829.603760
2014-04-10 17:12:12.518 PhysicsTest[4508:60b] The acceleration is: 0.000000 -860.666260
2014-04-10 17:12:12.534 PhysicsTest[4508:60b] The acceleration is: 0.000000 -831.616455
2014-04-10 17:12:12.568 PhysicsTest[4508:60b] The acceleration is: 0.000000 -514.745300
2014-04-10 17:12:12.585 PhysicsTest[4508:60b] The acceleration is: 0.000000 -1667.948853
2014-04-10 17:12:12.601 PhysicsTest[4508:60b] The acceleration is: 0.000000 -839.192383
2014-04-10 17:12:12.618 PhysicsTest[4508:60b] The acceleration is: 0.000000 -807.683167
2014-04-10 17:12:12.651 PhysicsTest[4508:60b] The acceleration is: 0.000000 -523.592285
What the hell?

Difficulty with multiple plot spaces in CorePLot

I have several graphs to be plotted over each other, and I need them to share an x axis of time, but have different Y-Axes... To do this, I know I have to create a new plot space for the 2nd through n-th graph, and add those plot spaces to the graph:
Here is a snippet from my "Add a new graph to the diagram" function
BOOL isNew=FALSE;
CPTXYPlotSpace *defaultPlotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
CPTXYPlotSpace *plotSpace=nil;
if([g_Data count]==1){
plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
NSLog(#"Reuse existing plot space");
}
else
{
NSLog(#"New plot space");
plotSpace = [[CPTXYPlotSpace alloc] init];
isNew=TRUE;
}
[dataDictionary setObject:plotSpace forKey:#"plotspace"];
float xSize=[mainGraphView bounds].size.width;
float ySize=[mainGraphView bounds].size.height;
float XRatio=(xSize-50.0)/xSize;
float YRatio=(ySize-50.0)/ySize;
NSDecimalNumber *plotWidth=[x_max decimalNumberBySubtracting:x_min];
plotWidth=[plotWidth decimalNumberByDividingBy:[NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:#"%0.2f",XRatio]]];
NSDecimalNumber *plotX=[x_min decimalNumberBySubtracting:[plotWidth decimalNumberBySubtracting:[x_max decimalNumberBySubtracting:x_min]]];
NSDecimalNumber *plotHeight=[y_max decimalNumberBySubtracting:y_min];
plotHeight=[plotHeight decimalNumberByDividingBy:[NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:#"%0.2f",YRatio]]];
NSDecimalNumber *plotY=[y_min decimalNumberBySubtracting:[plotHeight decimalNumberBySubtracting:[y_max decimalNumberBySubtracting:y_min]]];
NSLog(#"%#: XRange: Original: %# x %0.2f becomes %#",identifier,[x_max decimalNumberBySubtracting:x_min],XRatio,plotWidth);
NSLog(#"%#: YRange: %#-%# is %# x %0.2f becomes %#",identifier,y_min,y_max,[y_max decimalNumberBySubtracting:y_min],YRatio,plotHeight);
if(isNew){
plotSpace.xRange = defaultPlotSpace.xRange;
}
else
{
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:[plotX decimalValue] length:[plotWidth decimalValue]];
}
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:[plotY decimalValue]
length:[plotHeight decimalValue]];
NSLog(#"**********YPLOT IS FROM %# len %#",plotY,plotHeight );
plotSpace.allowsUserInteraction=TRUE;
if(isNew)[graph addPlotSpace:plotSpace];
CPTScatterPlot *newPlot = [[CPTScatterPlot alloc] initWithFrame:graph.bounds];
newPlot.identifier = identifier;
newPlot.dataSource = self;
CPTMutableLineStyle *lineStyle = [newPlot.dataLineStyle mutableCopy];
lineStyle.lineWidth = 2.0;
lineStyle.lineColor = graphColor;
newPlot.dataLineStyle = lineStyle;
[g_Plots addObject:newPlot];
[graph addPlot:newPlot toPlotSpace:plotSpace];
NSLog(#"Adding plot to graph system");
[graph addPlot:newPlot];
and my log:
2013-10-28 15:24:35.166 BodyMetrics[2234:303] -------[NEW PLOT FOR Pulse (bpm)]-----------------------------------------------------------
2013-10-28 15:24:35.169 BodyMetrics[2234:303] 85 rows for data: BM_Measure measuredate measuretype = 'Heart Pulse'
2013-10-28 15:24:35.173 BodyMetrics[2234:303] The size of the arrays for x and y are: 85;85
2013-10-28 15:24:35.173 BodyMetrics[2234:303] XMIN: 1380566085 XMAX: 1382980783
2013-10-28 15:24:35.173 BodyMetrics[2234:303] YMIN: 43 YMAX: 154
2013-10-28 15:24:35.173 BodyMetrics[2234:303] Reuse existing plot space
2013-10-28 15:24:35.174 BodyMetrics[2234:303] Pulse (bpm): XRange: Original: 2414698 x 0.95 becomes 2541787.36842105263157894736842105263157
2013-10-28 15:24:35.174 BodyMetrics[2234:303] Pulse (bpm): YRange: 43-154 is 111 x 0.90 becomes 123.333333333333333333333333333333333333
2013-10-28 15:24:35.174 BodyMetrics[2234:303] **********YPLOT IS FROM 30.666666666666666666666666666666666667 len 123.333333333333333333333333333333333333
2013-10-28 15:24:35.175 BodyMetrics[2234:303] Adding plot to graph system
2013-10-28 15:24:35.176 BodyMetrics[2234:303] Added... 1
2013-10-28 15:24:35.176 BodyMetrics[2234:303] Configure axes
2013-10-28 15:24:35.177 BodyMetrics[2234:303] Now addign Y axes...
2013-10-28 15:24:35.177 BodyMetrics[2234:303] Creating axis for Pulse (bpm)
2013-10-28 15:24:35.177 BodyMetrics[2234:303] Reusing the existing Y Axis...
2013-10-28 15:24:35.178 BodyMetrics[2234:303] This axes is from 43 to 154 being a range of 111 so the major ticks will bat 10.3 floats away, for an interval length of 10.7766990291262135922330097087378640776
2013-10-28 15:24:35.178 BodyMetrics[2234:303] About to add the following axes: 2 (
"<<<CPTXYAxis: 0x10040ca80> bounds: {{0, 0}, {959, 515}}> with range: <<CPTPlotRange: 0x60800027cc40> {1380438995.6315789473684210526315789474, 2541787.36842105263157894736842105263157}> viewCoordinates: {0, 50} to {959, 50}>",
"<<<CPTXYAxis: 0x10040d8f0> bounds: {{0, 0}, {959, 515}}> with range: <<CPTPlotRange: 0x60800027cd00> {30.666666666666666666666666666666666667, 123.333333333333333333333333333333333333}> viewCoordinates: {50, 0} to {50, 515}>"
)
2013-10-28 15:24:35.179 BodyMetrics[2234:303] Added
2013-10-28 15:24:35.179 BodyMetrics[2234:303] -------[NEW PLOT FOR Weight (Kg)]-----------------------------------------------------------
2013-10-28 15:24:35.181 BodyMetrics[2234:303] 44 rows for data: BM_Measure measuredate measuretype = 'Weight'
2013-10-28 15:24:35.183 BodyMetrics[2234:303] The size of the arrays for x and y are: 44;44
2013-10-28 15:24:35.183 BodyMetrics[2234:303] XMIN: 1380330622 XMAX: 1382957809
2013-10-28 15:24:35.183 BodyMetrics[2234:303] YMIN: 83.225 YMAX: 85.701
2013-10-28 15:24:35.183 BodyMetrics[2234:303] New plot space
2013-10-28 15:24:35.183 BodyMetrics[2234:303] Weight (Kg): XRange: Original: 2627187 x 0.95 becomes 2765460
2013-10-28 15:24:35.184 BodyMetrics[2234:303] Weight (Kg): YRange: 83.225-85.701 is 2.476 x 0.90 becomes 2.75111111111111111111111111111111111111
2013-10-28 15:24:35.184 BodyMetrics[2234:303] **********YPLOT IS FROM 82.9498888888888888888888888888889 len 2.75111111111111111111111111111111111111
2013-10-28 15:24:35.184 BodyMetrics[2234:303] Adding plot to graph system
2013-10-28 15:24:35.184 BodyMetrics[2234:303] Added... 2
2013-10-28 15:24:35.185 BodyMetrics[2234:303] Configure axes
2013-10-28 15:24:35.185 BodyMetrics[2234:303] Now addign Y axes...
2013-10-28 15:24:35.185 BodyMetrics[2234:303] Creating axis for Pulse (bpm)
2013-10-28 15:24:35.185 BodyMetrics[2234:303] Reusing the existing Y Axis...
2013-10-28 15:24:35.185 BodyMetrics[2234:303] This axes is from 43 to 154 being a range of 111 so the major ticks will bat 10.3 floats away, for an interval length of 10.7766990291262135922330097087378640776
2013-10-28 15:24:35.186 BodyMetrics[2234:303] Creating axis for Weight (Kg)
2013-10-28 15:24:35.186 BodyMetrics[2234:303] Adding a new Y axis...
2013-10-28 15:24:35.186 BodyMetrics[2234:303] This axes is from 83.225 to 85.701 being a range of 2.476 so the major ticks will bat 10.3 floats away, for an interval length of 0.240388349514563106796116504854368932038
2013-10-28 15:24:35.187 BodyMetrics[2234:303] About to add the following axes: 2 (
"<<<CPTXYAxis: 0x10040ca80> bounds: {{0, 0}, {959, 515}}> with range: <<CPTPlotRange: 0x60800027cc40> {1380438995.6315789473684210526315789474, 2541787.36842105263157894736842105263157}> viewCoordinates: {0, 50} to {959, 50}>",
"<<<CPTXYAxis: 0x10040d8f0> bounds: {{0, 0}, {959, 515}}> with range: <<CPTPlotRange: 0x60800027cd00> {30.666666666666666666666666666666666667, 123.333333333333333333333333333333333333}> viewCoordinates: {50, 0} to {50, 515}>"
)
2013-10-28 15:24:35.187 BodyMetrics[2234:303] Added
However my graphs do not scale correctly:
You're adding the plot to the graph twice, first with [graph addPlot:newPlot toPlotSpace:plotSpace]; and again with [graph addPlot:newPlot];. The second call moves the plot back to the default plot space which is configured for the first plot.
Remove the redundant call to -addPlot:.

Core-Plot : y Axis labels should start from 60

I need to draw a scatter plot, in which the x axis should intersect with y axis at (0,60).
I also need interval of 20 on the y Axis.
The problems I am facing right now are:
y axis is starting from 0
The gap between y axis labels example, from 60 - 80 is too much.
What I have done so far:
To set the intersection points:
x.orthogonalCoordinateDecimal = CPTDecimalFromString(#"60");
To set the major tick locations:
NSSet *majorTickLocations = [NSSet setWithObjects:[NSDecimalNumber zero],
[NSDecimalNumber numberWithUnsignedInteger:60],
[NSDecimalNumber numberWithUnsignedInteger:80],
[NSDecimalNumber numberWithUnsignedInteger:100],
[NSDecimalNumber numberWithUnsignedInteger:120],
nil];
y.majorTickLocations = majorTickLocations;
Any pointer in the direction will be helpful.
Regards,
Ishan
To make the axes cross at (0, 60), set the orthogonalCoordinateDecimal of each axis:
x.orthogonalCoordinateDecimal = CPTDecimalFromDouble(60.0);
y.orthogonalCoordinateDecimal = CPTDecimalFromDouble(0.0);
The axis labeling policy determines how the tick marks and labels are positioned. If you are providing the tick and label positions yourself (CPTAxisLabelingPolicyNone), you can put them anywhere you want. See the "Axis Labeling Policies" demo in the Plot Gallery example app for samples of each available labeling policy.

Resources