2
votes

I want to align the y axis labels of my scatter plot in Core Plot. Currently, the labels are like this:

16

12

8

4

How can I change they alignment to right :

16

12

_8

_4

I tried the following:

y.labelAlignment = CPTAlignmentRight;

It didn't work. How can I do this alignment?

Edit- Here is my code:

CPTAxis *y = axisSet.yAxis;    
y.title = @"Y Label";
y.titleTextStyle = axisTitleStyle;
y.titleOffset = -40.0f;       
y.axisLineStyle = axisLineStyle;
y.labelingPolicy = CPTAxisLabelingPolicyNone;
y.labelTextStyle = axisTextStyle;    
y.labelOffset = 16.0f;
y.majorTickLineStyle = axisLineStyle;
y.majorTickLength = 4.0f;
y.minorTickLength = 2.0f;    
y.tickDirection = CPTSignPositive;
y.labelAlignment = CPTAlignmentRight;
1
That should work. Can you show more of the axis setup code? - Eric Skroch
I came across this thread groups.google.com/forum/#!topic/coreplot-discuss/l38qGhfaZgY but am unable to understand what to do exactly. - Dinesh
So you have labels to the right of a vertical axis and you want the labels right-aligned, leaving a variable amount of space between the tick marks and the labels? - Eric Skroch
No. I want the labels to have a constant amount of space with the axis. If we see the graph, my labels are to the left of the axis. - Dinesh
The label offset is -40. So thats why the labels are displayed to the left of the y axis. - Dinesh

1 Answers

3
votes

You can specify the label direction independently from the tick direction now. To have the tick marks extend to the right of the axis while lining up the labels on the left side, use the following settings:

y.tickDirection = CPTSignPositive;
y.tickLabelDirection = CPTSignNegative;
y.labelOffset = 5.0;