2012-03-27 80 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;