# make-plots
The plots produced with `rivet-mkhtml` are really rendered with the command `make-plots`, which is called under the hood. The `make-plots` command can also be used to create figures from the simple .dat text format produced by `rivet-cmphistos` directly.
The `make-plots` script is quite powerful, and includes several options to modify plotting style, adding curves or fits and more. For use with Rivet, the syntax documented in this document should be provided in the .plot file.
Internally, `make-plots` the simple text format and converts them into PostScript or PDF files by creating a LaTeX file and running `latex`, `dvips`, and maybe `ps2pdf`.
## Usage
To run `make-plots` call
```
make-plots [options] file.dat [file2.dat ...]
```
All available options can be listed by running
```
make-plots --help
```
### Configuration files
`make-plots` typically takes the plotting instructions and settings from the input ascii files as described in the "Input Format" chapter. It is also possible though to pass a global configuration file to `make-plots` (cf. `--help`) which allows to specify/overwrite settings for certain plots or histograms in a plot on top of what the input files specify. This could be useful if the ascii files are generated automatically (e.g. with `rivet-mkhtml` or `compare-histos`) and you still want to apply custom plotting options.
An example for this looks like:
```
# BEGIN PLOT figures/MC_WJETS/W_mass.dat
XMin=60.0
XMax=100.0
LegendXPos=0.65
# END PLOT
.*myLOrun.yoda/D0_2008_S7554427/d01-x01-y01::Scale=1.0
```
Here first the options in the `PLOT` section of a specific ascii file are being amended/overwritten. The second part shows how to overwrite the `Scale` property of one specific histogram line using the ID of the histogram.
## Input Format
The ascii files which can be read by `make-plots` are divided into sections. There are four types of sections which are called `PLOT`, `HISTOGRAM`, `FUNCTION`, and `SPECIAL`. Every file must contain exactly one `PLOT` section and at least one section of the other three types. There may be multiple `HISTOGRAM`, `FUNCTION`, and `SPECIAL` sections.
Empty lines and lines starting with `#` are ignored, except for the section delimiters described below.
### PLOT
The `PLOT` section starts with
```
# BEGIN PLOT
```
and ends with
```
# END PLOT
```
Every file must have exactly one `PLOT` section. In this section global parameters are specified, like the axis labels, the plot title, size, … An empty `PLOT` section is perfectly legal, though.
In this section the following parameters can be set:
#### Titles, Labels
```
Title=
```
The title of the plot.
```
XLabel=
YLabel=
ZLabel=
```
Axis labels for the x-, y-, and z-axis.
```
XLabelSep=
YLabelSep=
ZLabelSep=
```
Distance between the axis label and the plot in units of `\labelsep`.
```
XMajorTickMarks=
YMajorTickMarks=
ZMajorTickMarks=
XMinorTickMarks=
YMinorTickMarks=
ZMinorTickMarks=
```
`make-plots` tries to guess the distance between tickmarks automatically. If you are not satisfied with its result, you can override this by setting `` to 1, 2, 5, or 10, and `` to the number of minor ticks you like. _Note_: These options are not available for logarithmic axes.
```
XTwosidedTicks=<0|1>
YTwosidedTicks=<0|1>
```
Draw tickmarks also on the upper and/or right side of the plot.
```
XCustomMajorTicks=
YCustomMajorTicks=
ZCustomMajorTicks=
```
To specify major ticks at arbitrary positions and/or with arbitrary labels. `` is a whitespace-separated list of format `value1 label1 value2 label2 ...`.
[//]: # TODO: allow use of YAML-style list syntax to clarify delimiters?
```
XCustomMinorTicks=
YCustomMinorTicks=
ZCustomMinorTicks=
```
To specify minor ticks at arbitrary positions. `` is a tab separated list of format `value1 value2 value3 ...`.
```
PlotXTickLabels=<0|1>
RatioPlotTickLabels=<0|1>
```
Disable/enable plotting of the tick labels in the plot and ratio plot (useful if multiple plots are to be combined manually later).
#### Axes
```
LogX=<0|1>
LogY=<0|1>
LogZ=<0|1>
```
Use a logarithmic x-, y-, or z-axis. Default is linear.
```
XMin=
XMax=
YMin=
YMax=
ZMin=
ZMax=
FullRange=<0|1>
ShowZero=<0|1>
```
Specify the plot range. By default the range is chosen such that all data is visible in linear plots, and the zero is visible. `ShowZero=0` suppresses plotting the zero in linear plots and thus zooms into the actual y-value range of the distribution. In logarithmic plots the automatic choice of `YMin` is limited to be not smaller than 2e-4*`YMax`, but manually you can specify any value. `FullRange=1` also overrides the 2e-4*`YMax` limit and plots the full range in y.
#### Normalization, Rebinning
```
NormalizeToIntegral=<1|0>
NormalizeToSum=<1|0>
Scale=
```
Normalize all histograms to their integral, to their sum of entries, or scale them by some arbitrary factor. Normalization and scale options in the `PLOT` section override the corresponding option in the `HISTOGRAM` section. The scale factor is applied after normalization.
```
Rebin=
```
Rebin all histograms in this plot. Syntax and functionality is the same as for the Rebin option in the `HISTOGRAM` section.
#### Sizes and Margins
```
PlotSize=
```
Size in x and y direction of the plot. This can be specified in any unit LaTeX understands.
```
LeftMargin=
RightMargin=
TopMargin=
BottomMargin=
```
Distance between the plot and the paper edge.
```
FrameColor=
```
Background color for the margin around the plot.
#### Legends
```
Legend=<0|1>
```
Display a legend in the plot.
```
CustomLegend=
```
Custom text that is added to the legend.
```
LegendXPos=
LegendYPos=
```
Position of the legend within the plot. Anchor point is the top left corner of the legend, so units typically range between 0.0 and 1.0.
```
LegendAlign=
```
Horizontal alignment of the legend: `LegendAlign=l` is the default and will create a left-aligned legend, while `LegendAlign=r` is right-aligned with the keys on the right hand side.
```
LegendOnly=
```
Whitespace separated list of IDs. These can be histograms or functions. The legend is only shown for the listed objects. Without this option, all plotted objects which have a title enter the legend. The legend titles are plotted in the given order, so there are cases in which it makes sense to use `LegendOnly` together with all histogram IDs. It is also possible to specify the legend order on an entry-by-entry basis using the `LegendOrder=` setting for each histogram or function.
#### Plotting Options
```
DrawOnly=
```
Whitespace separated list of histogram IDs. Only the histograms in this list are plotted, even if there are more histograms defined in the file. The histograms are plotted in the given order, so there are cases in which it makes sense to use `DrawOnly` together with all histogram IDs. This is especially useful for the `Stack` option. It is also possible to specify the plotting order on a histogram-by-histogram basis using the `PlotOrder=` setting for each histogram.
```
Stack=
```
Whitespace separated list of histogram IDs. The histograms will be added on top of each other. This is useful for example to compare data with background if the background has contributions from several histograms.
```
DrawSpecialFirst=<0|1>
DrawFunctionFirst=<0|1>
```
By default the `SPECIAL` and `FUNCTION` sections are plotted after the histograms. With these options you can override that behaviour.
```
ConnectGaps=<0|1>
```
If error bars are disabled and you want to bridge gaps in a histogram, you can set this parameter. By default it is off. Setting it in the `PLOT` section affects all histograms, but you can also set it in the `HISTOGRAM` section for individual histograms. The local setting overrides the global setting.
#### Comparison Plots
With the
```
RatioPlot=1
RatioPlotReference=
```
options you can create ratio plots for two or more histograms. Note that you must specify your reference data ID. This option is used by the `compare-histos` script.
```
RatioPlotMode=
```
By default, the ratio plot displays MC/Data. You can switch to (MC-data)/uncertainty (`deviation`) or Data/MC (`datamc`) with this option.
In ratio plots the following additional options are available and work in a similar way as their regular counterparts:
```
RatioPlotYLabel=
RatioPlotYMin=
RatioPlotYMax=
RatioPlotYSize=
RatioPlotErrorBandColor=
```
By default, the reference data is plotted using a yellow error band around the central value of the ratio plot. If you would rather have it plotted in the same style as in the main plot (e.g. with black errorbars), you can specify:
```
RatioPlotSameStyle=1
```
If you only want the ratio plot without showing the actual data distribution, you can switch off the main plot. This option implies `RatioPlot=1`:
```
MainPlot=0
```
#### Goodness of Fit
`make-plots` can calculate the goodness of fit between histograms and display the result in the legend. It is also possible to change the color of the margin around the plot depending on the GoF. This is useful to provide a quick overview when looking at many plots.
```
GofType=chi2
```
The type of GoF. The default is `chi2` and currently that’s the only option.
```
GofReference=
```
specifies the reference histogram to be used for the GoF calculation. If this option is omitted, the fallback is `RatioPlotReference`.
The GoF calculation is activated by two options:
```
GofLegend=<0|1>
GofFrame=
```
`GofLegend` calculates the GoF for all histograms and displays the results in the legend. With `GofFrame` you can specify a single histogram for which the GoF result will be shown in the legend and used to assign a color to the plot margins. Note that `FrameColor` overrides the color choice for the margin. You can use
```
GofFrameColor=
```
to specify the thresholds for the frame color. This option takes a list of `:` pairs, separated by whitespace. The default is `GofFrameColor=0:green 3:yellow 6:red!70`. Again, if you use `FrameColor`, this option is disabled.
#### Color Palettes for 2-dim Plots
With the option `ColorSeries` you can define a custom color palette for 2-dimensional plots. The syntax is the same as for the `\definecolorseries` command in the `xcolor` LaTeX package after the color series name, i.e. `{core-model}{method}[begin-model]{begin-spec}[end-model]{end-spec}`. For more information you can consult the [xcolor documentation](http://www.ctan.org/tex-archive/macros/latex/contrib/xcolor/xcolor.pdf). Here is an example:
```
ColorSeries={rgb}{last}[rgb]{1,0.97,0.94}[rgb]{0.6,0.0,0.05}
```
### HISTOGRAM
The `HISTOGRAM` section starts with
```
# BEGIN HISTOGRAM
```
and ends with
```
# END HISTOGRAM
```
There can be more than one `HISTOGRAM` section in a file. Histograms are identified by `` which can be any string _not_ containing whitespace.
#### Data Format
Lines starting with a number (positive or negative) are interpreted as data. Each line specifies one bin. The fields in each line must be separated by tabs, not spaces (this needs to be fixes some day). For 1-dimensional histograms the format can be
```
```
2-dimensional histograms are supported, too. They are plotted as colormap (errors are ignored) and specified as
```
```
#### Titles
```
Title=
```
Title of the histogram. This is used for the legend.
#### Linestyles
```
LineStyle=