Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I show whole numbers, not decimals, on a Core Plot Y axis?

I am plotting a line graph in using Core Plot and I want the Y axis labels to show as whole numbers. For example, my range is from 0 to 10 with an interval of 1, but the graph currently shows axis labels of 1.0, 2.0, 3.0, and so on.

How do I make it so that Core Plot shows the labels as 1, 2, 3, and so on?

like image 923
divya Avatar asked Feb 21 '23 11:02

divya


2 Answers

i am just posting code here, i have same issues before and solved that but currently i forgot which change i have done so please review below code you will get exact solution what you want.

It's working fine just need to test using this...

NSNumberFormatter *yAxisFormat = [[[NSNumberFormatter alloc] init] autorelease];
[yAxisFormat setNumberStyle:NSNumberFormatterNoStyle]; 

CPXYAxis *y = axisSet.yAxis;
y.axisLineStyle = lineStyle;
y.majorTickLineStyle = nil;
y.minorTickLineStyle = nil;
y.majorIntervalLength = CPDecimalFromString(@"20");
y.orthogonalCoordinateDecimal = CPDecimalFromString(@"0");
y.title = @"Number of Cards Learned";
y.titleOffset = 45.0f;
y.titleLocation = CPDecimalFromFloat(50.0f);
y.labelFormatter = yAxisFormat; 

if further issues then just inform me.

like image 182
Nilesh Kikani Avatar answered May 02 '23 01:05

Nilesh Kikani


Set the labelFormatter (and minorTickLabelFormatter if you're labeling the minor ticks) property on the axis. These are standard NSNumberFormatter objects.

like image 26
Eric Skroch Avatar answered May 02 '23 02:05

Eric Skroch