Coreplot in swift: change starting value of axis to 1

流过昼夜 提交于 2020-01-06 14:53:16

问题


I have a graph and I wan't that the x and the 2 y to start at 1 not 0.

![enter image description here][1]

This is how i setup the plotspaces:

//plotspace 1
    var plotSpace: CPTXYPlotSpace = graph.defaultPlotSpace as CPTXYPlotSpace
    var xRange = plotSpace.xRange.mutableCopy() as CPTMutablePlotRange
    var yRange = plotSpace.yRange.mutableCopy() as CPTMutablePlotRange
    xRange.length = self.maxX
    yRange.length = maxPoids
    plotSpace.xRange = xRange
    plotSpace.yRange = yRange
//plotspace2 (second y)
    var plotSpace2: CPTXYPlotSpace = CPTXYPlotSpace()
    var xRange2 = plotSpace2.xRange.mutableCopy() as CPTMutablePlotRange
    var yRange2 = plotSpace2.yRange.mutableCopy() as CPTMutablePlotRange
    xRange2.length = self.maxX
    yRange2.length = maxEau
    plotSpace2.xRange = xRange2
    plotSpace2.yRange = yRange2
    graph.addPlotSpace(plotSpace2)

How can I do that?


回答1:


The location of a plot range is the left end (on the x-axis) or bottom end (on the y-axis). Give each range a location of one (1) and adjust the length to the max - min (i.e., one in this case).



来源:https://stackoverflow.com/questions/27324882/coreplot-in-swift-change-starting-value-of-axis-to-1

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