Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove negative axes from coreplot(scatter plot) in iphone

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

like image 382
sujith1406 Avatar asked Jun 20 '11 11:06

sujith1406


2 Answers

Here are some examples pulled from the CPTTestApp example included with Core Plot:

  1. Setting plot ranges:

    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 to NSRange—they have a starting location and length. The length can be negative if you want the reverse the direction of an axis.

  2. Limiting the length of axes:

    yAxis.visibleRange   = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(2)
                                                        length:CPTDecimalFromInteger(3)];
    yAxis.gridLinesRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(2)
                                                        length:CPTDecimalFromInteger(3)];
    
  3. Changing the visible area:

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

    You can also set padding on graph.plotAreaFrame to inset the plot area to create room for axis labels and titles.

Eric

like image 51
Eric Skroch Avatar answered Oct 04 '22 19:10

Eric Skroch


Use plotRangeWithLocation: length: methods.

-(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)];
}
like image 32
Cyprian Avatar answered Oct 04 '22 20:10

Cyprian