utariq
utariq

Reputation: 37

Core plot objective-c, i want to make range of y-axis of my graph similar to excel graph automatic axis range/scaling

I am making a graph in objective-c by using core plot library. i want to make my graph`s y-axis automatic scale like in excel the range produced automatically.

Axis format in excel:

minimum: auto
maximum: auto
major unit: auto
minor unit: auto
major tick mark type: outside
minor tick mark type: none
axis labels: next to Axis

I tried yAxis.labelPolicy = CPTAxisLabelingPolicyAutomatic but I didnt produced same range as excel graph is producing.

Upvotes: 2

Views: 2194

Answers (1)

Eric Skroch
Eric Skroch

Reputation: 27381

The labeling policy handles making the labels but doesn't affect the scale of the axis. For that you need to use the plot space. The -scaleToFitPlots: method will adjust both the x and y ranges so that they exactly fit the data for all of the plots in the array. For example, to make the default plot space fit all plots in the graph, use

[graph.defaultPlotSpace scaleToFitPlots:[graph allPlots]];

Upvotes: 2

Related Questions