Coreplot in swift: change starting value of axis t

2019-09-06 16:54发布

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条回答
▲ chillily
2楼-- · 2019-09-06 17:27

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).

查看更多
登录 后发表回答