The Plot object is used to control the details of how plots are made and displayed by DEMETER programs. It is useful to consider how ATHENA works in order to understand the relationship of the Plot object to the rest of DEMETER. In ATHENA, the plot controls are separate from the controls for the parameters of any individual data set. For example, the range over which data are plotted in energy or R-space is, in some, sense, a global parameter not associated with a particular data set. The Plot object serves this role. The details of the plot in DEMETER are global. To plot a plottable object (Data, Path, or any of the Path-like objects), DEMETER consults the Plot object for those details.
To make the Plot object readily accessible at all times in your program, the po method is a method of the base class and is inherited by all DEMETER objects. Thus, given any object, you can “find” the Plot object like so:
Any method of the plot object is easily called by chaining with the po method. For example to start a new plot (as opposed to overplotting), you do this
The start_plot method reinitializes the Plot object to begin a new plot. Along with clearing the plotting display, this restarts the trace colors and resets the plot title.
- my @eplot = (e_mu => 1, e_bkg => 1,
- e_norm => 0, e_der => 0,
- e_pre => 1, e_post => 1,
- e_i0 => 0, e_signal => 0,
- e_markers => 1,
- emin => -200, emax => 2000,
- space => 'E',
- );
- $data -> po -> set(@eplot);
- $data -> po -> start_plot;
- $data -> plot;
This example demonstrates the common and useful plot showing the data along with the background function and the regressed polynomials used to normalize the data. Note that the Plot object has a number of boolean attributes which turn features of the energy plot on and off. Also note that the range of the plot is set by the values of the emin and emax attributes of the Plot object. Also note that, as was discussed in the chapter on the Data object, there is no need to explicitly perform the data normalization or background removal. DEMETER knows what needs to be done to bring the data up to date for plotting and will perform all necessary chores before actually generating the plot. This allows you to focus on what you need to accomplish. |
One final point about this example. I have created the @eplot array to hold the attributes of the Plot object. I then pass that array as the argument of the set method of the Plot object. Those attributes could be listed as explicit arguments of the set method. As always in perl, there's more than one way to do it.
- my @eplot = (e_mu => 1, e_bkg => 1,
- e_norm => 1, e_der => 0,
- e_pre => 0, e_post => 0,
- e_i0 => 0, e_signal => 0,
- e_markers => 1,
- emin => -200, emax => 2000,
- space => 'E',
- );
- $data -> po -> set(@eplot);
- $data -> bkg_flatten(0);
- $data -> po -> start_plot;
- $data -> plot;
This example shows how to plot data and background function after normalization. |
- my @eplot = (e_mu => 1, e_bkg => 1,
- e_norm => 1, e_der => 0,
- e_pre => 0, e_post => 0,
- e_i0 => 0, e_signal => 0,
- e_markers => 1,
- emin => -200, emax => 2000,
- space => 'E',
- );
- $data -> po -> set(@eplot);
- $data -> bkg_flatten(1);
- $data -> po -> start_plot;
- $data -> plot;
- my @eplot = (e_mu => 1, e_bkg => 0,
- e_norm => 0, e_der => 1,
- e_pre => 0, e_post => 0,
- e_i0 => 0, e_signal => 0,
- e_markers => 0,
- emin => -20, emax => 120,
- space => 'E',
- );
- $data -> po -> start_plot;
- $data -> set(name=>'derivative') -> plot;
- $data -> po -> e_norm(1);
- $data -> set(name=>'norm. deriv.') -> plot;
- my @eplot = (e_mu => 1, e_bkg => 0,
- e_norm => 0, e_der => 0,
- e_pre => 0, e_post => 0,
- e_i0 => 1, e_signal => 1,
- e_markers => 0,
- emin => -20, emax => 120,
- space => 'E',
- );
- $data -> po -> start_plot;
- $data -> plot;
DEMETER saves arrays containing I₀ and the signal channel, which can then be plotted along with the data. DEMETER takes care to scale these arrays so that they plot nicely with the data. |
- my @common = (bkg_rbkg => 1.5,
- bkg_spl1 => 0, bkg_spl2 => 18,
- bkg_nor2 => 1800,
- bkg_flatten => 1,
- );
- my @data = (Demeter::Data -> new(),
- Demeter::Data -> new(),
- );
- foreach (@data) { $_ -> set(@common) };
- $data[0] -> set(file => "$where/data/fe.060.xmu",
- name => 'Fe 60K', );
- $data[1] -> set(file => "$where/data/cu010k.dat",
- name => 'Cu 10K', );
- ## decide how to plot the data $plot -> set(e_mu => 1, e_bkg => 0,
- e_norm => 1,
- e_pre => 0, e_post => 0,
- e_zero => 1,
- emin => -30, emax => 150,
- );
- $data[0] -> po -> start_plot;
- foreach (@data) { $_ -> plot('E') };
- $data -> po -> start_plot;
- $data -> po -> kweight(2);
- $data -> plot('k');
Again, DEMETER will take care of the background removal when you request a plot in k-space. Note that the k-weight to use for plotting is an attribute of the Plot object. |
- $data -> po -> start_plot;
- $data -> po -> set(kweight=>2, chie=>1);
- $data -> plot('k');
Here the x-axis of the χ(k) plot has been converted to absolute energy. |
- $data -> po -> start_plot;
- $data -> plot('k123');
- $data -> po -> set(kweight => 2, r_pl => 'm', space => 'r', );
- $data -> po -> start_plot;
- $data -> plot -> plot_window;
- $data -> po -> set(kweight => 2, r_pl => 'e', space => 'r');
- $data -> po -> start_plot;
- $data -> plot;
- $data -> set(name=>'Real part');
- $data -> po -> set(r_pl => 'r', );
- $data -> plot;
- $data -> set(name=>'Imaginary part');
- $data -> po->set(r_pl => 'i', );
- $data -> plot;
- $data -> po -> start_plot;
- $data -> plot('r123');
- $data -> po -> start_plot;
- $data -> po -> kweight(2);
- $data -> plot('rmr');
- $data -> po -> set(kweight => 2, q_pl => 'r');
- $data -> po -> start_plot;
- $data -> plot('q');
Plotting the back-transformed χ(q) is specified by plotting in “q”. The part of the complex χ(q) is specified using the q_pl attribute of the Plot object. |
- $data -> po -> start_plot;
- $data -> po -> kweight(2);
- $data -> plot('kq');
The final specialty plot type in DEMETER is the “kq plot”. This overplots χ(k) with the real part of χ(q). |