0

How do I get reference to a plot space? In case there is only one plot space, we can use the following code to create and get reference to the default plot space:

CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) graph.defaultPlotSpace

So we can add plot to this plot space afterwards. The trouble comes when there is more than one plot space in the graph, and we try to add plot to a non-default plot space from another method (that is, the relevant plot space was created in another method). There should be something about array of plot spaces, but I can't get it. Thanks

HSH
  • 111
  • 1
  • 9

1 Answers1

0

You have several options:

  • Set the identifier for the new plot space and use -plotSpaceWithIdentifier: to retrieve a reference from the graph.

  • Use -plotSpaceAtIndex: to refer to plot spaces in the order they were added to the graph. The default plot space is at index 0.

  • Keep a reference to each new plot space elsewhere in your app (for example, in an instance variable).

Eric Skroch
  • 27,381
  • 3
  • 29
  • 36
  • Thanks my friend. I chose the second option, but slightly different because I don't know how to use '-plotSpaceAtIndex:'. So, I use '[[graph allPlotSpaces] objectAtIndex:index]'. It seems to be producing the result I expect. – HSH Jan 08 '15 at 05:17