0

合計テスト数のy軸と
時間のx軸があります

以下は、プロットに使用しているコードです。

- (NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot {  
    NSUInteger recordplot;  

    if (plot.identifier == @"Plot Error")  
    {  
        recordplot = [HourErroroArray count];  

        recordplot--;  
    }  

    return recordplot;  
}  


- (NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index {  
    NSDecimalNumber *num = nil;  
    int eTemp1;  
    int eHour1;  
    int eMin1;  
    int eSec1;  
// Number of the X axis asked  
    if (fieldEnum == CPScatterPlotFieldX)  
    {  

    if (plot.identifier == @"Plot Error")  
        {  
        eHour1=[[HourErroroArray objectAtIndex:index]intValue ];  
        eMin1=[[MinErrorArray objectAtIndex:index]intValue ];  
        eSec1=[[SecErrorArray objectAtIndex:index]intValue ];  

        eTemp1=eHour1*eMin1*eSec1;  

        num = (NSDecimalNumber *)[NSDecimalNumber numberWithInt:eTemp1];  
        }  
    }  
// Number of the Y axis asked  
    else if (fieldEnum == CPScatterPlotFieldY)  
     {   
        if (plot.identifier == @"Plot Error")  
        {  
          num = (NSDecimalNumber *)[NSNumber numberWithInteger:index];  

        }  

     }   

    return num;  

}  

グラフがプロットされているのがわかりますが、x 軸に平行な直線のみです。

!->y 軸、_ ->x 軸、および . ->線は値をプロットしています

Y軸  
!  
!   
! …………  
!
______________ x 軸

しかし、私は次のようなものが欲しいです:

http://www.buggyprogrammer.co.uk/2010/10/03/using-core-plot-to-draw-line-graphs/

上下の線ではないかもしれませんが、少なくともある程度の角度があります。

4

1 に答える 1

0

x と y の値を入れ替えた可能性があります。y 値がインデックスで、x 値が計算値であるということでしょうか?

それ以外の場合は、いくつかの NSLog ステートメントを挿入-numberForPlot:field:recordIndex:し、数値 (eTemp1、eHour1、eMin1、eSec1) が期待どおりであることを確認します。

【コメントを受けて追記しました】

プロット スペースのプロット範囲をチェックして、データにとって妥当であることを確認します。y 範囲の長さが大きすぎると、プロットが圧縮され、水平線のように見えます。プロット範囲でよくある間違いは、範囲を作成するときに長さを最終値と間違えることです。CPTPlotRange は NSRange と同じように機能します。実験として、プロット スペース法-scaleToFitPlots:を使用して、データがプロット範囲を満たすようにしてみてください。例については、Mac CPTTestApp を参照してください。

于 2011-06-14T17:49:29.283 に答える