core-plot iOS reversed Y axis

筅森魡賤 提交于 2019-12-02 02:59:34

问题


I would like to use core-plot to display a water depth graph (updated in real time) but I can't figure out how to reverse the Y axis, so that the X axis (representing the time domain) is on the top of my UIView and the Y axis grows towards the bottom with positive values.

EDIT

It would be even better if I could draw axes like this:
- X axis is time
- Y axis is from 0 to X (X > 0) and on the top there is 0, on the bottom there is X
- X axis is on the bottom

ASCII version:

0 |
1 |
.
.
.
x |
--------------------------

0 1 2 3 4 5 6 7 ...


回答1:


You can use a negative length for the plot range to reverse the direction of an axis. For example (from the axis demo in CPTTestApp):

plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0.0)
                                                length:CPTDecimalFromDouble(-10.0)];


来源:https://stackoverflow.com/questions/6037318/core-plot-ios-reversed-y-axis

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