我在代码下生成散点图:
- (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];
}
输出低于:
但是,我需要显示x和y轴的majorline和minorline ......!
像这样的y-0.5,1.0,1.5 ......!和x-0.5,1.0,1.5 ......!我想在图片下面输出:
任何人帮助我....!
谢谢...!
答案 0 :(得分: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;