Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Customize Plot Area of CorePlot in Graph

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.

like image 933
aks.knit1108 Avatar asked Jan 17 '23 20:01

aks.knit1108


1 Answers

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.

like image 121
Eric Skroch Avatar answered Jan 21 '23 16:01

Eric Skroch