2013-10-25 159 views
0

我繪製的Unix時間戳VS權重,所以我的x軸的範圍,作爲一個例子,就是: 1380330622直通1382696991核心圖軸困難

Y軸爲:83 86通左右...

共有40個條目。

我的陰謀範圍基本上設置爲最小< - >每張最大的,和圖形數據顯示了罰款...但我不能讓我的軸,以顯示在所有...

最初高x軸的數字是造成分配一個巨大的主刻度數,這就是解決了,但是沒有軸:

enter image description here

-(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; 





} 

這裏是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 

回答

0

這是問題的至少一部分:CPTDecimalFromDouble(1380340622.0f);

該數字是過大,無法通過浮法值(由「F」後綴被迫)準確表示。 Unix的時間是一個整數,所以嘗試這樣的事情:

y.orthogonalCoordinateDecimal = CPTDecimalFromLong(1380330622); 

編輯基於問題的新信息:

你軸線位置是數據的範圍之外。例如,x軸在y = 82.0時穿過y軸,但繪圖範圍從83.225開始。

x.orthogonalCoordinateDecimal = CPTDecimalFromDouble(y_min); 
y.orthogonalCoordinateDecimal = CPTDecimalFromDouble(x_min); 

如果要始終與軸銷以在繪圖區域內一定點(例如,邊緣或中間的一個),而不管可視數據的範圍的,則可以使用軸約束,而不是正交座標。

x.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0]; 
y.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0]; 
+0

謝謝...我有固定的,但仍然沒有果汁不是他的軸: -/ – JeremyLaurenson

+0

是什麼x和y的範圍?數據源是否返回x值的時間戳或索引? –

+0

我將時間戳轉換爲整數。我現在也計算了自2000年以來的小時數,所以數字要小得多。上面顯示的原始範圍 – JeremyLaurenson