您建议使用哪种算法或公式将y轴上的标签设置为CorePlot中5或10的倍数?
我基本上想获得偶数编号,例如:5、10、15、20或100、105、110、115 ...,并将y标签的最大数量设置为10。
任何想法都将受到欢迎!谢谢!!
最佳答案
这由“标签政策”控制。您有几种选择:
typedef enum _CPTAxisLabelingPolicy {
CPTAxisLabelingPolicyNone, ///< No labels provided; user sets labels and tick locations.
CPTAxisLabelingPolicyLocationsProvided, ///< User sets tick locations; axis makes labels.
CPTAxisLabelingPolicyFixedInterval, ///< Fixed interval labeling policy.
CPTAxisLabelingPolicyAutomatic, ///< Automatic labeling policy.
CPTAxisLabelingPolicyEqualDivisions ///< Divide the plot range into equal parts.
} CPTAxisLabelingPolicy;
如果知道刻度线的间隔,请保留默认的标签策略(固定间隔)并将
majorIntervalLength
设置为所需间隔。您还可以使用自动策略让Core Plot选择间隔。使用preferredNumberOfMajorTicks
属性可以提示要制作多少个刻度线。关于objective-c - 在核心图中将轴标签设置为5或10的倍数的算法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9708126/