I am plotting graph using core plot. I am trying to plot my graph on plot area, but it contains white background. But I want to plot graph with my own background. This is my code.
// setting frame of graph
CGRect frame = [self.hostingView bounds];
self.graph = [[[CPTXYGraph alloc] initWithFrame:frame] autorelease];
// Add some padding to the graph, with more at the bottom for axis labels.
self.graph.plotAreaFrame.paddingTop = 10.0f;
self.graph.plotAreaFrame.paddingRight = 10.0f;
self.graph.plotAreaFrame.paddingBottom = 25.0f;
self.graph.plotAreaFrame.paddingLeft = 30.0f;
// set background color of plot area by fill property and CPTColor
self.graph.plotAreaFrame.plotArea.fill=[(CPTFill *)[CPTFill alloc] initWithColor: [CPTColor colorWithComponentRed:0.8 green:0.8 blue:0.8 alpha:1.0]];
// add graph to hosting view by hostedGraph property of hostingView
self.hostingView.hostedGraph = self.graph;
In above code I tried to change color but I want to draw horizontal dotted lines for each ticks on y axis.
Set the majorGridLineStyle
and/or minorGridLineStyle
on the y-axis to draw horizontal lines at the major and minor tick locations, respectively.
Use the dashPattern
and patternPhase
properties of the line style to make a dotted line. See Apple's Quartz 2D docs for details on how those properties work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With