[ Demeter main page ] [ Cookbook main page ]

Plotting and Configuration

Is there a plotting tutorial?

Sort of. The Demeter distribution comes with a handy, interactive script that serves to teach plotting basics. It is examples/plot in the distribution. Also right here. This demonstrates, with plots and code, how to make several common types of plots using Demeter.

Just run the script, it should be self-explanatory. You'll need to make sure it can find the data file. If you run it in the examples/ directory, you should have no trouble.

If possible, you should install Term::ANSIColor. The messages written to the screen are a bit easier to read with a bit of color, although the script works correctly if Term::ANSIColor is not found.

How do I change how plots are made?

When Demeter starts, a Plot object gets created automatically. While it is allowed to maintain more than one plot object, that is not normally necessary. If you want to change some aspect of how data gets plotted, for instance the energy range, this idiom works well:

   1 $data -> po -> set({emin=>-100, emax=>300});
   2 $data -> plot('E');

You can also save a reference to the default plot object like so:

   1 my $plot = $data -> po;

Then use it directly rather than the chained reference via the po method.

In this way you can change any of the Plot attributes. Note, though, that to vertically offset a trace, you need to set the y_offset attribute of the Data object and to scale a trace, you need to set the plot_multiplier attribute of the Plot object.

How do I overplot data? How do I start a new plot.

Overplotting data is done simply by repeated calls to the plot method for one or more Data objects.

   1 $data[0] -> plot('E');
   2 $data[1] -> plot('E');

To start a new plot -- i.e. clear the old plot and reinitialize the trace colors -- call the start_plot method of the plot object. This example, overplots two chi(k) spectra, waits 5 seconds, the makes a new plot with the chi(R) spectra.

   1 $data[0] -> plot('k');
   2 $data[1] -> plot('k');
   3 sleep 5;
   4 $data[0] -> po -> start_plot;
   5 $data[0] -> plot('R');
   6 $data[1] -> plot('R');

How do I change Demeter's configuration parameters?

Much of Demeter's behavior is tunable via the configuration subsyetm.

You can find out what configuration parameters are available.

   1 my $config = Ifeffit::Demeter->config;
   2 my @config_groups = $config -> groups;
   3 my @group_params  = $config -> parameters('bkg');

The first line puts a reference to the Config object in a handy variable. The second line returns a list with the names of all configuration groups. The third line returns all parameters of the bkg group.

This line writes a nicely formatted, complete description of a parameter.

   1 print $config -> describe_param('clamp', 'medium'), "\n";
  • clamp -> medium
        "The numeric value for the medium spline clamp."
      type     : positive integer
      default  : 12
      demeter  : 12
      minint   : 0
      maxint   : 10000000000000
    

You can get the value of any parameter

   1 my $value = $config -> default('clamp', 'medium'), "\n";  # $value equals 12

and you can set the value of a parameter like so.

   1 $config -> set_default('clamp', 'medium', 15), "\n";
   2 my $value = $config -> default('clamp', 'medium'), "\n";  # $value now equals 15


Demeter/Cookbook/PlottingAndConfiguration (last edited 2008-02-13 22:37:51 by BruceRavel)