Chapter 12 Internal Data Visualization12.1 GAMELANThe data values and tables that we have introduced in the previous section can be visualized using built-in features of WHIZARD. To be precise, WHIZARD can write LATEX code which incorporates code in the graphics language GAMELAN to produce a pretty-printed account of observables, histograms, and plots. GAMELAN is a macro package for MetaPost, which is part of the TEX/LATEX family. MetaPost, a derivative of Knuth’s MetaFont language for font design, is usually bundled with the TEX distribution, but might need a separate switch for installation. The GAMELAN macros are contained in a subdirectory of the WHIZARD package. Upon installation, they will be installed in the appropriate directory, including the gamelan.sty driver for LATEX. WHIZARD uses a subset of GAMELAN’s graphics macros directly, but it allows for access to the full package if desired. An (incomplete) manual for GAMELAN can be found in the share/doc subdirectory of the WHIZARD system. WHIZARD itself uses a subset of the GAMELAN capabilities, interfaced by SINDARIN commands and parameters. They are described in this chapter. To process analysis output beyond writing tables to file, the write_analysis command described in the previous section should be replaced by compile_analysis, with the same syntax: compile_analysis (analysis-tags) { options } where analysis-tags, a comma-separated list of analysis objects, is optional. If there are no tags, all analysis objects are processed. The options script of local commands is also optional, of course. This command will perform the following actions:
The resulting PostScript or PDF file – the file name is the name of the data file with the extension replaced by .ps or .pdf, respectively – can be printed or viewed with an appropriate viewer such as gv. The viewing command is not executed automatically by WHIZARD. Note that LATEX will write further files with extensions .log, .aux, and .dvi, and GAMELAN will produce auxiliary files with extensions .ltp and .mpx. The log file in particular, could overwrite WHIZARD’s log file if the basename is identical. Be careful to use a value for $out_file which is not likely to cause name clashes. 12.1.1 User-specific changesIn the case, that the SINDARIN compile_analysis command is invoked and the flag named ?analysis_file_only is not changed from its default value false, WHIZARD calls the process-/analysis-specific makefile triggering the compilation of the LATEX code and the GAMELAN plots and histograms. If the user wants to edit the analysis output, for example changing captions, headlines, labels, properties of the plots, graphs and histograms using GAMELAN specials etc., this is possible and the output can be regenerated using the makefile. The user can also directly invoke the GAMELAN script, whizard-gml, that is installed in the binary directly along with the WHIZARD binary and other scripts. Note however, that the LATEX environment for the specific style files have to be set by hand (the command line invocation in the makefile does this automatically). Those style files are generally written into share/texmf/whizard/ directory. The user can execute the commands in the same way as denoted in the process-/analysis-specific makefile by hand. 12.2 Histogram Display12.3 Plot Display12.4 GraphsGraphs are an additional type of analysis object. In contrast to histograms and plots, they do not collect data directly, but they rather act as containers for graph elements, which are copies of existing histograms and plots. Their single purpose is to be displayed by the GAMELAN driver. Graphs are declared by simple assignments such as graph g1 = hist1 The first declaration copies a single histogram into the graph, the second one copies two histograms and a plot. The syntax for collecting analysis objects uses the & concatenation operator, analogous to string concatenation. In the assignment, the rhs must contain only histograms and plots. Further concatenating previously declared graphs is not supported. After the graph has been declared, its contents can be written to file (write_analysis) or, usually, compiledd by the LATEX/GAMELAN driver via the compile_analysis command. The graph elements on the right-hand side of the graph assignment are copied with their current data content. This implies a well-defined order of statements: first, histograms and plots are declared, then they are filled via record commands or functions, and finally they can be collected for display by graph declarations. A simple graph declaration without options as above is possible, but usually there are options which affect the graph display. There are two kinds of options: graph options and drawing options. Graph options apply to the graph as a whole (title, labels, etc.) and are placed in braces on the lhs of the assigment. Drawing options apply to the individual graph elements representing the contained histograms and plots, and are placed together with the graph element on the rhs of the assignment. Thus, the complete syntax for assigning multiple graph elements is graph graph-tag { graph-options } This form is recommended, but graph and drawing options can also be set as global parameters, as usual. We list the supported graph and drawing options in Tables 12.1 and 12.2, respectively.
12.5 Drawing optionsThe options for coloring lines, filling curves, or choosing line styles make use of macros in the GAMELAN language. At this place, we do not intend to give a full account of the possiblities, but we rather list a few basic features that are likely to be useful for drawing graphs. ColorsGAMELAN knows about basic colors identified by name:
black, white, red, green, blue, cyan,
magenta, yellow
More generically, colors in GAMELAN are RGB triplets of numbers (actually, numeric expressions) with values between 0 and 1, enclosed in brackets:
(r, g, b)
To draw an object in color, one should apply the construct withcolor color to its drawing code. The default color is always black. Thus, this will make a plot drawn in blue: $draw_options = "withcolor blue" and this will fill the drawing area of some histogram with an RGB color: $fill_options = "withcolor (0.8, 0.7, 1)" DashesBy default, lines are drawn continuously. Optionally, they can be drawn using a dash pattern. Predefined dash patterns are
evenly, withdots, withdashdots
Going beyond the predefined patterns, a generic dash pattern has the syntax
dashpattern (on l1 off l2 on …)
with an arbitrary repetition of on and off clauses. The numbers l1, l2, … are lengths measured in pt. To apply a dash pattern, the option syntax dashed dash-pattern should be used. Options strings can be concatenated. Here is how to draw in color with dashes: $draw_options = "withcolor red dashed evenly" and this draws error bars consisting of intermittent dashes and dots: $err_options = "dashed (withdashdots scaled 0.5)" The extra brackets ensure that the scale factor 1/2 is applied only the dash pattern. HatchingAreas (e.g., below a histogram) can be filled with plain colors by the withcolor option. They can also be hatched by stripes, optionally rotated by some angle. The syntax is completely analogous to dashes. There are two predefined hatch patterns:
withstripes, withlines
and a generic hatch pattern is written
hatchpattern (on w1 off w2 on …)
where the numbers l1, l2, … determine the widths of the stripes, measured in pt. When applying a hatch pattern, the pattern may be rotated by some angle (in degrees) and scaled. This looks like $fill_options = "hatched (withstripes scaled 0.8 rotated 60)" Smooth curvesPlot points are normally connected by straight lines. If data are acquired by statistical methods, such as Monte Carlo integration, this is usually recommended. However, if a plot is generated using an analytic mathematical formula, or with sufficient statistics to remove fluctuations, it might be appealing to connect lines by some smooth interpolation. GAMELAN can switch on spline interpolation by the specific drawing option linked smoothly. Note that the results can be surprising if the data points do have sizable fluctuations or sharp kinks. Error barsPlots and histograms can be drawn with error bars. For histograms, only vertical error bars are supported, while plot points can have error bars in x and y direction. Error bars are switched on by the ?draw_errors flag. There is an option to draw error bars with ticks: withticks and an alternative option to draw arrow heads: witharrows. These can be used in the $err_options string. SymbolsTo draw symbols at plot points (or histogram midpoints), the flag ?draw_symbols has to be switched on. |