Petar
Petar

Reputation: 2283

Core plot: grid lines background color

I want to be able to put background color in the spaces between the grid lines of the y axis. Can this be achieved with core plot ? If so, how ?

Any help and/or example code will be much appreciated.

Thank you,

Petar

Upvotes: 4

Views: 2012

Answers (1)

Eric Skroch
Eric Skroch

Reputation: 27381

You can use the alternatingBandFills property to set the fill between successive major ticks. Here's an example with two different colors:

axis.alternatingBandFills = [NSArray arrayWithObjects:[CPTColor redColor],
                                                      [CPTColor greenColor], nil];

The array can contain any combinination of CPTFill, CPTColor, CPTGradient, and/or CPTImage objects. Blank (transparent) bands can be created by using [NSNull null] in place of some of the CPTFill objects. You can use as many different fills as you want; the axis will cycle through all of them and then repeat the pattern until all of the spaces are filled.

Axes also support what Core Plot calls "limit bands". This is a way to fill a section within a specific plot range. These don't automatically repeat like the band fills do.

The Axis Demo in the Plot Gallery example app shows both features.

Upvotes: 7

Related Questions