我使用coreplot,我想绘制两个图,1)Bar Plot w.r.t Y1轴2)Scatter Plot w.r.t Y2 axis,如下图所示,具有不同的值集。
通过参考CorePlotTestApp示例中的代码,我设法通过下面的代码在右侧创建Y2轴。
CPTXYAxis *y2 = [[(CPTXYAxis *)[CPTXYAxis alloc] initWithFrame:CGRectZero] autorelease];
//y2.labelingPolicy = CPTAxisLabelingPolicyAutomatic;
y2.orthogonalCoordinateDecimal = CPTDecimalFromString(@"10");
y2.minorTicksPerInterval = 1;
y2.preferredNumberOfMajorTicks = 2;
y2.labelOffset = -20.0f;
y2.titleOffset = -23.0f;
y2.coordinate = CPTCoordinateY;
y2.plotSpace = plotSpaceRightYaxis;
y2.axisLineStyle = lineStyle;
y2.majorTickLineStyle = lineStyle;
y2.minorTickLineStyle = lineStyle;
//y2.visibleRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(0) length:CPTDecimalFromInteger(20)];
y2.title = @"Y2Title";
y2.labelTextStyle = textStyle;
y2.titleLocation = CPTDecimalFromInteger(4);
y2.axisConstraints = [CPTConstraints constraintWithUpperOffset:0.0];
graph.axisSet.axes = [NSArray arrayWithObjects:x, y,y2,nil];
我可以绘制条形图和散点图,但是左边只有Y1轴,但我想绘制它相对于Y2轴,所以我应该如何处理,请帮助我,等待你的回复。
此致 兰吉特。