0
votes

I am using core plot to make this scatter plot graph. Is there a way to make it so that all the points in my graph will be displayed above the x-axis? There are no negative values in my graph. All the values in my graph are from 60.00 to 64.00. Right now my graph looks like this

enter image description here

But is there a way I can make sure that there are no data points that are displayed below the x axis and to the left of the y axis.

2

2 Answers

0
votes

If you know exactly where the points are going to lie, then you can set the orthogonalCoordinateDecimal value of the axes so that all of the points are found within the first quadrant. This code is taken from DatePlot.m in the Plot_Gallery_iOS example project:

//Found in renderInLayer
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
CPTXYAxis *x          = axisSet.xAxis;
x.majorIntervalLength         = CPTDecimalFromFloat(oneDay);

/* Change the 2.0 to another value and the x axis will intersect the y axis at y = newVal*/
x.orthogonalCoordinateDecimal = CPTDecimalFromDouble(newVal);

CPTXYAxis *y = axisSet.yAxis;
y.majorIntervalLength         = CPTDecimalFromDouble(0.5);
y.minorTicksPerInterval       = 5;

/* Change the oneDay to another value and the y axis will intersect the x axis at x = newVal*/
y.orthogonalCoordinateDecimal = CPTDecimalFromFloat(oneDay); //oneDay * 2

You can update this at any time if you get dynamic data. Just get reference to the axis you need (graph -> axisSet -> x/y Axis) and then update it with the new value.

0
votes

Set the vertical plotrange so that it starts at 0, not at the lowest value in your dataset:

...
CPTPlotRange *plotRange = [CPTPlotRange plotRangeWithLocation: CPTDecimalFromDouble(0)
                                                       length: CPTDecimalFromDouble(maxValue)];
plotSpace.globalYRange = plotRange;
plotSpace.yRange = plotRange;
...

maxValue is the largest value in your dataset.