iphoneobjective-cioscore-plot

core-plot iOS reversed Y axis


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


Solution

  • 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)];