核心图:增加x轴上的刻度之间的空间? [英] Core Plot: Increase space between ticks on the x-axis?

查看:52
本文介绍了核心图:增加x轴上的刻度之间的空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码可以在x轴上打勾和标记:

I have this code for making ticks and labels on the x-axis:

    CPTAxis *x = axisSet.xAxis;
    x.title = @"Hour of Day";
    x.titleTextStyle = axisTitleStyle;
    x.titleOffset = 15.0f;
    x.axisLineStyle = axisLineStyle;
    x.labelingPolicy = CPTAxisLabelingPolicyNone;
    x.labelTextStyle = axisTextStyle;
    x.majorTickLineStyle = axisLineStyle;
    x.majorTickLength = 4.0f;
    x.tickDirection = CPTSignNegative;
    CGFloat dateCount = [timestamps count];
    NSMutableSet *xLabels = [NSMutableSet setWithCapacity:dateCount];
    NSMutableSet *xLocations = [NSMutableSet setWithCapacity:dateCount];
    NSInteger i = 0;
    for (NSString *date in timestampStrings) {
        CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:date textStyle:x.labelTextStyle];
        CGFloat location = i++;
        label.tickLocation = CPTDecimalFromCGFloat(location);
        label.offset = x.majorTickLength;
        if (label) {
            [xLabels addObject:label];
            [xLocations addObject:[NSNumber numberWithFloat:location]];
        }
    }
    x.axisLabels = xLabels;
    x.majorTickLocations = xLocations;

我想知道是否可以扩大每个刻度线之间的距离,因为现在看起来就像一个挤在一起的烂摊子,与这些点不对齐.有什么办法可以在每个刻度之间留出更多的空间,例如10个像素?谢谢!

I was wondering if I could expand the distance between each tick, because right now it just looks like a squished together mess that does not align with the points. Is there any way to make more space in between each tick, say 10 pixels? Thanks!

推荐答案

假设您使用 CPTXYGraph 及其 CPTXYPlotSpace .使用 plotSpace.globalXRange plotSpace.xRange 属性,您可以调整X轴的适当比例.
globalXRange 定义整个绘图区域,而 xRange 定义其可见空间.如果不使用滚动,则 xRange 必须等于 globalXRange .

Assuming you use CPTXYGraph and its CPTXYPlotSpace. Using the plotSpace.globalXRange and plotSpace.xRange properties you can adjust proper scale for the X-axis.
The globalXRange defines the whole plot area, while the xRange defines its visible space. If you do not use scrolling, then xRange must be equal to globalXRange.

这篇关于核心图:增加x轴上的刻度之间的空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆