How to add titles below the bars in Bar CHart created from Core Plot?

196 views Asked by At

Hi I need to show the String titles below the bars of my Bar Chart created from Core Plot. I have many places in Core Plot framework but didn't find how to put text below the bars? I need to show titles just like shown in the attached image.

Please suggest!

enter image description here

1

There are 1 answers

1
Eric Skroch On

There are a couple of ways to make axis labels that are not numeric representations of the data value.

If you are plotting categorical data, you can set the scale type of the plot space to show categorical labels and return the text of the label from the datasource for the plot value (e.g., the bar location for a bar plot).

From the "Vertical Bar Chart" demo in the Plot Gallery example app:

// setup
[barPlotSpace setScaleType:CPTScaleTypeCategory forCoordinate:CPTCoordinateX];

If you're not plotting categorical data or you just need more control over the labels, you can create custom axis labels. Set the axis labelingPolicy to CPTAxisLabelingPolicyNone, create a set of axis labels, and assign it to the axisLabels property. There are several demos in the example apps including the "Composite Plot" demo in the Plot Gallery example app. With CPTAxisLabelingPolicyNone, the tick marks and labels are independent, so if you want tick marks, you also need to set the majorTickLocations and/or minorTickLocations.