the axis is drawn under the plot in core plot

强颜欢笑 提交于 2019-12-11 20:11:58

问题


I have a graph, and I want to add two blue axes to this graph, in addition to x-axis and y-axis. However, these blue axes appear under the plot. Any idea how to bring the blue axes on top of the plot? Thank you in advance.

    blueAxisList = [[NSMutableDictionary alloc] init];


    CPTXYAxis *blueAxis = [blueAxisList objectForKey:name];
    blueAxis = [[CPTXYAxis alloc] init];
    blueAxis.coordinate = CPTCoordinateX;

    blueAxis.plotSpace = plotSpace;

    CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle];

    lineStyle.lineWidth = 3.f;

    blueAxis.axisLineStyle = lineStyle;
    blueAxis.minorTickLineStyle = nil;
    blueAxis.majorTickLineStyle = nil;
    blueAxis.labelingPolicy = CPTAxisLabelingPolicyNone;

    // Line cap on lhs
    CPTLineCap *lineCap = [CPTLineCap lineCap];
    lineCap.size      = CGSizeMake(8., 60.);
    lineCap.lineStyle = lineStyle;

    lineCap.lineCapType = CPTLineCapTypeRectangle;
    const double axisLength = plotSpace.xRange.lengthDouble;
    blueAxis.visibleAxisRange = [CPTPlotRange plotRangeWithLocation:plotSpace.xRange.location length:CPTDecimalFromDouble(axisLength)];
    blueAxis.axisLineCapMax = lineCap;

    NSMutableArray *axesList= [graph.axisSet.axes mutableCopy];

    [axesList addObject: blueAxis];
    graph.axisSet.axes = axesList;

回答1:


Instead using axes to draw lines across the plot, use additional plots. You can draw both lines with the same plot if they use the same line style. Add the blue plot to the graph after the green one to have it drawn on top.



来源:https://stackoverflow.com/questions/25997224/the-axis-is-drawn-under-the-plot-in-core-plot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!