Storing Plots - Python Question

If you want to maintain the list of plots across save/load, you'll need to use pickling. Check out Stone-D's Toolkit as it will do all the dirty work.

I recommend tracking each plot index rather than the CyPlot itself as this will be better for pickling. The reason is that plot indexes are constant for all time while I don't know if pickling a CyPlot (handle to a C++ object) will work.

You can use

Code:
index = CyMap().plotNum(x, y)

to get a plot's index and

Code:
pPlot = CyMap().plotByIndex(index)

to get the plot itself.
 
Not sure if you mean to save/load or just for use in a function. EmporerFool did a pretty good job laying out the Save/Load part.

For a list, you would do something like this...

Code:
pPlotList = [] # Makes a "list"
pPlotList.append(pPlot1) # Adds the plot to the list
pPlotList.append(pPlot2) # Adds another plot to the list


# Now, there are two plots in the list. Say you want to do something to each plot...


for pPlot in pPlotList:
     pPlot.doSomething()   #Each plot's .doSomething() function will be run.
 
Back
Top Bottom