-1

I am using Line Graph of Core Plot in my project. The thing is when I kept the data of my X-axis and Y-axis like: 1,2,3....10, everything worked fine. But now the data is like: X-axis: 0, 150, 500.... and on Y-axis: 0,1000,2000 and so on.

So now my graph is not fully visible in the given area. I know it is because the range on my Y-axis is getting too high and it is not visible. Some code that might possibly the reason for it:

// Setup scatter plot space
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.allowsUserInteraction = YES;

plotSpace.xRange                = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(0.0) length:CPTDecimalFromInteger(8)];
plotSpace.yRange                = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(0.0) length:CPTDecimalFromInteger(5)];

// Restrict y range to a global range
CPTPlotRange *globalYRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(-2.5)
                                                          length:CPTDecimalFromDouble(5.0)];
plotSpace.globalYRange = globalYRange;

CPTPlotRange *globalXRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(-0.2)
                                                          length:CPTDecimalFromDouble(17.0)];

plotSpace.globalXRange=globalXRange;

This graph is when my data range is getting too high

halfer
  • 19,824
  • 17
  • 99
  • 186
user3153627
  • 1,385
  • 1
  • 8
  • 11

2 Answers2

1

The xRange and yRange are too small to display all of the plot data.

plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(0)
                                                length:CPTDecimalFromInteger(500)]; 
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(0)
                                                length:CPTDecimalFromInteger(2000)];
Eric Skroch
  • 27,381
  • 3
  • 29
  • 36
0

enter image description here

No luck :( It becomes as per its shown above. I dont want to compress the data. The distance between the months should be as same as the figure posted in the question. The Y axis data is still not getting visible completely. My global X and Y range is like this

CPTPlotRange *globalYRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(-2.5) length:CPTDecimalFromDouble(5.0)]; plotSpace.globalYRange = globalYRange;

CPTPlotRange *globalXRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(-0.2)
                                                          length:CPTDecimalFromDouble(17.0)];

plotSpace.globalXRange=globalXRange;
user3153627
  • 1,385
  • 1
  • 8
  • 11
  • This contribution to the page seems to be an addendum and not an answer. The OP seems not to have visited for a year, and so I think this can safely be deleted - voting as NAA. – halfer Nov 22 '15 at 23:22