remove negative axes from coreplot(scatter plot) in iphone
Asked Answered
D

2

5

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

Distillation answered 20/6, 2011 at 11:10 Comment(0)
B
15

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

Bandage answered 21/6, 2011 at 1:59 Comment(2)
I'm trying to figure out core plot. Can you tell me where I can find explanation on CPTXYPlotSpace. I see you have a range that looks like it should go from 0 to -10. If you did that, I'd think that it would include negative values.Ulotrichous
Exactly. The location of a plot range is the left end (for the x-axis) or bottom (for the y-axis). A positive length counts upwards towards higher values while a negative length counts down to lower values.Bandage
B
1

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)];
}
Blakemore answered 20/6, 2011 at 11:20 Comment(1)
i have given this ,so there are no numbers shown in this region but the axes are still visible....and also how to change the visible area of graph?Distillation

© 2022 - 2024 — McMap. All rights reserved.