Jean
Jean

Reputation: 2625

Core Plot - Plot label going beyond boundary

Am using Core Plot to display a line chart. The label for plot gets cut when it is near (though not outside) the border as seen below

enter image description here

though, as you can see in the XCode Storyboard (below pic) that the border of each graph is well above (height) and there doesn't seem to be a reason why the label of the plot is getting cut.

enter image description here

I have set the graph Hosting View's frame to match the frame size in XCode.

    self.graphHostView = [(CPTGraphHostingView *) [CPTGraphHostingView alloc]
                          initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y,
                                                   self.view.frame.size.width, self.view.frame.size.height)];
    self.graph = [[CPTXYGraph alloc] initWithFrame:self.graphHostView.bounds];

Also, how do I get rid of the label name in X-Axis (the leftmost 1.0 and rightmost 5.0)?

EDITED

@EricSkroch , I tried the following :

CASE 1 Setting plotAreaFrame.paddingTop=20.0 plotAreaFrame.paddingBottom=15.0

enter image description here

CASE 2 graph.paddingTop=20.0 graph.paddingBottom=15.0 (didn't set anything for plotAreaFrame)

enter image description here

CASE 3 Setting both the above (plotAreaFrame & graph padding) plotAreaFrame.paddingTop=20.0 plotAreaFrame.paddingBottom=15.0 graph.paddingTop=20.0 graph.paddingBottom=15.0

enter image description here

CASE 4 - Seems to be the best output! (though the top is still cropped) Setting top padding to 0 for both plotArea & frame graph.paddingTop=0.0 plotAreaFrame.paddingTop=0.0

enter image description here

CASE 5 If I try to increase either plotAreaFrame or graph's top-padding, this is what i get graph.paddingTop=5.0

enter image description here

Upvotes: 2

Views: 892

Answers (1)

Eric Skroch
Eric Skroch

Reputation: 27381

Add some padding to the graph and/or plot area frame (paddingLeft, paddingRight, etc.). This will push the plot area in away from the edges of the graph leaving room for the labels.

Upvotes: 2

Related Questions