Remove negative axes from coreplot (scatter plot) on iphone

How to remove negative axes from corePlot (scatterplot) in iphone and how to set the visible area of ​​the graph?

+5
source share
2 answers

Here are a few examples extracted from the CPTTestApp example included in Core Plot:

  • Range of parameter values:

    CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
    plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0.0)
                                                    length:CPTDecimalFromDouble(-10.0)];
    plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0.5)
                                                    length:CPTDecimalFromDouble(1500.0)];
    

    Remember that plot ranges are similar NSRange- they have an initial location and length. The length can be negative if you want the axis direction to be inverse.

  • Axle Length Limit:

    yAxis.visibleRange   = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(2)
                                                        length:CPTDecimalFromInteger(3)];
    yAxis.gridLinesRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(2)
                                                        length:CPTDecimalFromInteger(3)];
    
  • Visible area change:

    graph.paddingLeft = 60.0;
    graph.paddingTop = 60.0;
    graph.paddingRight = 60.0;
    graph.paddingBottom = 60.0;    
    

    You can also set the padding on graph.plotAreaFrameto insert a plot area to create space for labels and axis headers.

+15

plotRangeWithLocation: length:.

-(void)initXYAxesRanges{

    //Set graph ranges for x and y planes
    CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
    plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0)
                                                   length:CPDecimalFromFloat(10];
    plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0)
                                                   length:CPDecimalFromFloat(10)];
}
+1

All Articles