Reputation: 6933
Just like the title says, is there a way to bring grid lines into foreground (namely, in front of the graph, but behind symbols)? What I have right now is:
And my code is as follows (using Swift 3):
let gridLineStyle = CPTMutableLineStyle()
gridLineStyle.lineWidth = 0.75
gridLineStyle.lineColor = CPTColor.white()
let bottomXAxis = axisSet.axis(for: .X, at: 0) as! CPTXYAxis
bottomXAxis.labelingPolicy = .none
axisLineStyle.lineWidth = 2.0
bottomXAxis.majorTickLineStyle = axisLineStyle
bottomXAxis.majorTickLength = 4.0
bottomXAxis.minorTicksPerInterval = 0
bottomXAxis.labelTextStyle = axisTitleStyle
bottomXAxis.labelOffset = -2.0
bottomXAxis.majorGridLineStyle = gridLineStyle
Upvotes: 1
Views: 107
Reputation: 27381
Plot symbols are drawn in the same layer as the scatter plot. You can rearrange the drawing layers with the topDownLayerOrder
, but that still keeps the plots together.
One possible solution is to use a partially transparent fill for the area fills under the scatter plots. That would allow the grid line to show through. Another solution would be to draw your own grid lines with another scatter plot. Use separate plots to draw the fills, the grid, and the plot symbols so you can control the layering.
Upvotes: 1