Table of Contents

Plot

pl = Graphics.Plot(Data, Options) plots spectra, lists of data points and response functions and returns a Graphics object, an A4 page in landscape with a frame, axes and the curves. Graphics.ToSVG(pl) and Graphics.ToPS(pl) turn it into the text of an svg or a PostScript file. pl = Graphics.Plot(G, GammaL, GammaG, NE, Options) plots a response function, broadened. Several curves can be drawn in one frame, as a waterfall plot shifted above each other, as a color map, or as a grid of panels.

Input

Output

The frame

The option “Frame” is a table of options:

Line styles

The option “LineStyle” is a list of styles, {style1, style2, …}, each a table of options:

There are always at least three styles: style 1 is black, style 2 red and style 3 blue. A style given in “LineStyle” changes only the options it names, so {“LineStyle”, {[2] = { {“LineColor”,0x00A000}}}}, or {“LineStyle”, { {}, { {“LineColor”,0x00A000}}}}, makes style 2 green and keeps the width of style 2 and the styles 1 and 3. A style beyond the third that is not given is a copy of the default style 1.

Which style goes to which curve:

When the curves of a list run out of styles they start again from style 1. They cycle through all styles, at least three, or through the first “LineStyleCycle” styles. Two colors that alternate therefore need “LineStyleCycle”: {“LineStyle”, {Orange, Green}} alone gives orange, green, blue (the default style 3), orange, …; with {“LineStyleCycle”,2} it gives orange, green, orange, green, … “LineStyleCycle” can not be larger than the number of styles.

Waterfall plots

With “WaterfallShift” or “UseResonantEnergy” the curves of a list are drawn above each other: curve $n$ at WaterfallOffset + $(n-1)$ WaterfallShift, or at WaterfallOffset plus its resonant energy. The values are multiplied by “Scale” before they are shifted. With “UseResonantEnergy” the vertical axis reads the incoming energy of RIXS spectra, also when the incoming energies are not equally spaced. “UseResonantEnergy” needs a Spectra object and can not be combined with “Nrow” and “Ncolumn”.

Color maps

With {“ColorMap”,true} the curves of a list are drawn as a color map, a bitmap of “NPixelX” by “NPixelY” pixels inside the frame. Each curve lies at the height it would have in a waterfall plot, or, without the waterfall options, at its number $n$. The heights must increase or decrease from curve to curve, and a color map needs at least two curves on a common energy mesh: it can not be made of lists of points, and not combined with “Nrow” and “Ncolumn”. With “Interpolate” the map is interpolated linearly in energy and between neighboring curves; without it each pixel takes the nearest point, the boundary between two curves lies half way between them, and the pixels are drawn as sharp squares.

The value at a pixel is the imaginary part, or the real part with {“plotIm”,false}, after “Negate” and “Scale”. The built-in color scale goes from white to “Color” as “Saturation” times the value goes from 0 to 1. A “ColorFunction” f(Re, Im) gets both parts and returns red, green and blue, each from 0 to 1 (values outside are clipped); it can show the intensity on a scale of its own, a logarithmic scale, or the sign or the phase of a response function.

Grids of panels

A matrix valued response function, and a Spectra object with “Nrow” and “Ncolumn”, is drawn as a grid of panels, one curve each, with the first curve (the element $G_{11}$) in the top left corner, row by row. All panels share the plot range of the “Frame”. The off-diagonal panels can show a different vertical range: from $(Y_{min} - s)\, c$ to $(Y_{max} - s)\, c$, with $s$ = “ShiftOffDiagonal” and $c$ = “ScaleOffDiagonal”, so that $c < 1$ magnifies the off-diagonal elements by $1/c$. The numbers on the vertical axis are those of the diagonal panels. To draw some of the elements in one frame instead, select them with “SpectraStart”, “SpectraStep” and “SpectraStop”: the diagonal of an $N \times N$ matrix is element 1 and every $(N+1)$-th after it.

Example

Three peaks as a Spectra object and as a response function, several curves in one frame, a waterfall plot and a color map.

Input

Example.Quanty
-- a response function with three poles, at -2, 0.5 and 3 eV with weights 0.3, 0.5 and 0.2,
-- and a spectrum made from it, broadened by a Lorentzian of 0.2 eV
G = ResponseFunction.New({ {0, -2, 0.5, 3}, {0.3, 0.5, 0.2}, mu = 0, type = "ListOfPoles" })
S = ResponseFunction.ToSpectra(G, {{"Emin",-5}, {"Emax",5}, {"NE",1000}, {"GammaL",0.2}})
 
-- write a Graphics object to an svg file that fills the window of a web browser
function Save(pl, name)
  local file = io.open(name..".svg", "w")
  file:write(Graphics.ToSVG(pl, {{"RelativeSize",true}}))
  file:close()
end
 
-- 1. without options: the real part red and the imaginary part blue, the vertical axis from -1 to 1
Save(Graphics.Plot(S), "Plot_1_default")
 
-- 2. the intensity -Im S, in a frame chosen by hand
Frame = {{"Xmin",-4}, {"Xmax",4}, {"Ymin",-0.2}, {"Ymax",5.5}, {"FirstYTick",0}, {"dYTick",1},
         {"XLabel","energy (eV)"}, {"YLabel","intensity"}, {"XLMargin",0.1}, {"YAxis",-10}}
Save(Graphics.Plot(S, {{"plotRe",false}, {"Negate",true}, {"Frame",Frame}}), "Plot_2_intensity")
 
-- 3. the response function itself, broadened by a Lorentzian of 0.2 eV; the energies are those of the frame
Save(Graphics.Plot(G, 0.2, {{"Frame",{{"Xmin",-4}, {"Xmax",4}, {"Ymin",-5.5}, {"Ymax",5.5}, {"FirstYTick",-4}, {"dYTick",2},
                                     {"XLabel","energy (eV)"}, {"YLabel","G(E)"}, {"XLMargin",0.1}}}}), "Plot_3_response_function")
 
-- 4. four curves in one frame, the intensity broadened by 0.2, 0.3, 0.5 and 0.8 eV, alternating orange and green
Curves = {}
for k, Gamma in ipairs({0.2, 0.3, 0.5, 0.8}) do
  Curves[k] = ResponseFunction.ToSpectra(G, {{"Emin",-5}, {"Emax",5}, {"NE",1000}, {"GammaL",Gamma}})
end
Orange = {{"LineWidth",0.003}, {"LineColor",0xFF8000}}
Green  = {{"LineWidth",0.003}, {"LineColor",0x00A000}}
Save(Graphics.Plot(Curves, {{"plotRe",false}, {"Negate",true}, {"Frame",Frame},
                            {"LineStyle",{Orange, Green}}, {"LineStyleCycle",2}}), "Plot_4_several_curves")
 
-- 5. the same curves as a waterfall plot, in the default styles, made smaller by Scale and each shifted up by 2 from the one before
Save(Graphics.Plot(Curves, {{"plotRe",false}, {"Negate",true}, {"Scale",0.35}, {"WaterfallShift",2},
                            {"Frame",{{"Xmin",-4}, {"Xmax",4}, {"YTicks",false}, {"XAxis",-10}, {"YAxis",-10},
                                      {"XLabel","energy (eV)"}, {"YLabel","intensity, shifted"}, {"XLMargin",0.06}}}}), "Plot_5_waterfall")
 
-- 6. the levels split by Delta from 0 to 3 eV, as a color map with Delta on the vertical axis
Series = {}
for k = 0, 60 do
  local Delta = 0.05*k
  Series[k+1] = ResponseFunction.ToSpectra(ResponseFunction.New({ {0, -0.4*Delta, 0.6*Delta}, {0.4, 0.6}, mu = 0, type = "ListOfPoles" }),
                                           {{"Emin",-3}, {"Emax",3}, {"NE",600}, {"GammaL",0.2}})
end
Save(Graphics.Plot(Series, {{"plotRe",false}, {"Negate",true}, {"WaterfallOffset",0}, {"WaterfallShift",0.05},
                            {"ColorMap",true}, {"Color",0x0000C0}, {"Saturation",0.2}, {"NPixelX",300}, {"NPixelY",300},
                            {"Frame",{{"Xmin",-2}, {"Xmax",3}, {"dYTick",0.5}, {"YFormat","%.1f"}, {"XAxis",-10}, {"YAxis",-10},
                                      {"XLabel","energy (eV)"}, {"YLabel","Delta (eV)"}, {"XLMargin",0.1}}}}), "Plot_6_color_map")

The script prints nothing; it writes the six plots as svg files. The plot without options shows the default vertical range from -1 to 1, which cuts the peaks. A Lorentzian of weight $w$ and full width $\Gamma$ is $2w/\Gamma$ high in $-\mathrm{Im}\,G$, here 3, 5 and 2. In the fourth plot the two styles alternate because of “LineStyleCycle”; the waterfall plot uses the default styles black, red and blue, which start again at the fourth curve.

Table of contents