2012-03-27 54 views
1

我下面的生成代碼散點圖點:我需要顯示的X和Y軸的主要和次要線和散點圖顯示核心,情節

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
     [self generateDataSamples]; 

    CPTGraphHostingView *hostingview=[[CPTGraphHostingView alloc] initWithFrame:self.view.bounds]; 
    [self.view addSubview:hostingview]; 

    graph=[[CPTXYGraph alloc] initWithFrame:self.view.bounds]; 
    hostingview.hostedGraph =graph; 

    CPTScatterPlot *datasourceLinePlot =[[CPTScatterPlot alloc] init]; 
    datasourceLinePlot.dataSource =self; 

    [graph addPlot:datasourceLinePlot]; 

    [datasourceLinePlot release]; 
    [graph release]; 
    [hostingview release]; 

} 

輸出如下:

enter image description here

但是,我需要爲x和yaxis顯示majorline和minorline ...!

像這樣y-0.5,1.0,1.5 ....!和x-0.5,1.0,1.5 ...!

我要輸出如下圖:

enter image description here

任何一個與我幫助....!

謝謝......!

回答

1

你只需要設置主要和次要刻度信息(樣本爲x軸如下圖所示):

CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle]; 
lineStyle.lineColor = [CPTColor blackColor]; 
lineStyle.lineWidth = 2.0f; 

CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet; 
axisSet.xAxis.axisLineStyle = lineStyle; 
axisSet.xAxis.majorTickLineStyle = lineStyle; 
axisSet.xAxis.minorTickLineStyle = lineStyle; 
axisSet.xAxis.majorIntervalLength = CPTDecimalFromString(@"5"); 
axisSet.xAxis.majorTickLength = 7.0f; 
axisSet.xAxis.majorTickLength = 7.0f;