Introduction to Coding Workspace Objects
Introduction
The components of a Workspace Object
Note: Throughout this discussion I use “axes” as a singular noun meaning “the thing that gets created by MATLAB when you enter the command axes()”.
At a minimum, each graph must include 3 axes. Even though you only see one axes, there are actually 3 of them stacked on top of each other. Using multiple axes stacked on top of each other allows more formatting options, such as different colored gridlines. It also givs each graph 3 userdata properties, each of which is used by rave for a particular purpose. The 3 axes are:
- handles.allgraphs(ai) = this is the main axes… the one in which you actually plot the data. The userdata of this axes
- handles.fakeax(ai) = this is the next axes down. This axes doesn’t really do anything, but you can use it if you need to plot something at an intermediate layer. Important: The udata for your graph MUST be stored in this axes’s userdata property, i.e. set(handles.fakeax(ai),’userdata’,udata) and udata=get(handles.fakeax(ai),’userdata’,udata).
- handles.fakerax(ai) = the bottom axes. This axes is used to display the graph’s background color and gridlines.
These three axes are created by the function ravenewgraph, which is ALWAYS run when the user makes a new graph and before your graph’s creation function is run. Thus these axes will already exist when your function gets run, so you don’t need to create these. You can access them using the fields indicated above.
IMPORTANT: Any plotting commands (e.g. plot,line,scatter,patch,surf,text) MUST take one of the above axes as a parent (unless you are making a matrix graph, described below). ALSO – BEWARE: many “high level” plotting commands will reset the userdata property of the axes. So you will need to set it again AFTER you finish plotting. For example, handles.allgraphs(ai)’s userdata should contain the keyword for your graph, something like “scatter”, but after you plot into the axes, it may get reset to an empty matrix. So check at the end of your graph creation function that it still says “scatter”. Otherwise rave won’t know which tabs to load when the user selects your graph (among other problems).