Making Changes to Function Graphics Code
QUESTION: Is there a way to modify the function graphics code that comes with IDL 8 and above? It is driving me crazy that there is no way to obtain the values of a plot function that I set in the INIT method of the object. I am thinking in particular of properties like Margin and Position.
What I would really like to do is write code like this.
p = plot(Findgen(20)) Print, p.margin
ANSWER: The answer to this question is provided by someone who actually knows something about function graphics. (Coyote and I have decided not to learn about them in any detail until the documentation more or less matches the functionality.) This answer has been lightly edited for clarity, but can be found in full in this Friday the 13th, 2012 article in the IDL newsgroup.
If you are fearless, don't mind rolling up your sleeves and perhaps your pantlegs, and enjoy the thought of diving deep (well, just six routines deep) into the "internal" .pro routines, it's pretty straightforward to answer the question "How?"
If you have none of these qualities, remain ashore and read no further. Contact IDL Technical Support with a feature request, and return to the safety of your home.
There's no reverse engineering since the .pro code is exposed. But there is hacking.
You have set sail to Terra Incognita, where a secret dialect is fluently spoken only by the natives known as The Second Floor*. Here there be undocumented IDL.
As a shortcut to getting to the crux of your question, execute the following slightly illegal statement from the IDL Workbench.IDL> p = plot(/Test, Margin=[0,0,0], /Debug)
This will cause IDL to stop with the following error:% MARGIN must have 1 or 4 elements.
All the display geometry calculation is in an editor window showing the routine in which you've stopped.
Set a breakpoint in the method, recompile, RETALL, then re-run with some valid input.
If you have the mad IDL debugging skilz, you'll see that the MARGIN value is likely discarded when other values are derived from it. By itself it never appears to be stored as a property of your plot object, such as in an obvious member variable.
If you back your way slowly and carefully out of the call stack (Show no fear! New Graphics can smell fear!), you may be able to discern how the derived values are used in subsequent calculations.
Of course the harder questions to answer are, "How do I change this to do what I want?" and the more generic "Why was it implemented this way?" These are exercises left for the reader.
*I'm on the third floor. We don't get capitalization up here.
Note that if you are running IDL on the Windows 7 operating system it will do you no good to set a breakpoint in IDL code that lives in the IDL distribution directories. You have no permission to write to those directories (although you will have no indication this is the case, or that anything is wrong with what you are trying to do, it just won't work). Copy the IDL code to a directory you do have permission to write into (say, the temp directory) and work with the code there.
Version of IDL used to prepare this article: IDL 8.1.