| Both sides previous revisionPrevious revision | |
| documentation:language_reference:objects:graphics:functions:plot [2026/11/12 22:24] – Maurits W. Haverkort | documentation:language_reference:objects:graphics:functions:plot [2026/11/16 23:19] (current) – Maurits W. Haverkort |
|---|
| {{indexmenu_n>999}} | {{indexmenu_n>999}} |
| ====== Plot ====== | ====== Plot ====== |
| | ;;# |
| | <color #ed1c24>Modified in 0.9.1</color> |
| | ;;# |
| |
| ### | ### |
| //pl = Graphics.Plot(Data, Options)// plots spectra, lists of data points and response functions and returns a [[documentation:language_reference:objects:graphics:start|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. | //pl = Graphics.Plot(Data, Options)// plots spectra, lists of data points, interpolating functions and response functions and returns a [[documentation:language_reference:objects:graphics:start|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. |
| ### | ### |
| |
| * a [[documentation:language_reference:objects:spectra:start|Spectra]] object, as made by //CreateSpectra//, //CreateResonantSpectra// or //ResponseFunction.ToSpectra//. A Spectra object with several spectra is drawn as several curves. | * a [[documentation:language_reference:objects:spectra:start|Spectra]] object, as made by //CreateSpectra//, //CreateResonantSpectra// or //ResponseFunction.ToSpectra//. A Spectra object with several spectra is drawn as several curves. |
| * a list of points //{ {x1, y1}, {x2, y2}, ...}//. The points are drawn at their own //x// and joined in the order of the list, so they need not be equally spaced. The //y// are real or complex numbers; a real //y// is the real part, so a list of real data is plotted with //{"plotIm",false}//. | * a list of points //{ {x1, y1}, {x2, y2}, ...}//. The points are drawn at their own //x// and joined in the order of the list, so they need not be equally spaced. The //y// are real or complex numbers; a real //y// is the real part, so a list of real data is plotted with //{"plotIm",false}//. |
| * a list of curves, //{C1, C2, ...}//, each a Spectra object, a list of points or a response function. The response functions are broadened by the fields //GammaL// and //GammaG// of the list, //{C1, C2, ..., GammaL = 0.2}//, and evaluated at //"PlotPoints"// energies of the plot range. | * an [[documentation:language_reference:objects:interpolatingfunction:start|interpolating function]] //f//. It is evaluated at //"PlotPoints"// + 1 equally spaced points of the plot range and at its own points //f.x// inside that range (the data points, or for a //DKBSpline// the radial points of the quadrature of the atom), and drawn through these points. A narrow feature between the equally spaced points, such as a 1s orbital near the nucleus, is therefore not lost. A function with a continuous derivative (//Spline//, //HermiteCSpline//, a //BSpline// of degree 2 or more, a //DKBSpline//) is drawn as a smooth curve of cubic pieces with the values and slopes of the function at their ends, so that it stays smooth when the picture is enlarged; other functions are drawn with straight pieces. Like every drawn line, the curve is thinned (see below): it uses only as many pieces as it needs. Without //"Xmin"// and //"Xmax"// the plot range runs from the first to the last point of //f//. The values are real, so they are drawn with //{"plotIm",false}//. <color #ed1c24>New in 0.9.1</color> |
| | * a list of curves, //{C1, C2, ...}//, each a Spectra object, a list of points, an interpolating function or a response function. The response functions are broadened by the fields //GammaL// and //GammaG// of the list, //{C1, C2, ..., GammaL = 0.2}//, and evaluated at //"PlotPoints"// + 1 equally spaced energies of the plot range. |
| * //G// : a [[documentation:language_reference:objects:responsefunction:start|response function]]. It is evaluated at the energies of the plot range, from //"Xmin"// to //"Xmax"// of the //"Frame"//, by default from -1 to 1. A matrix valued (block) response function is drawn as a grid of panels, one for each matrix element. | * //G// : a [[documentation:language_reference:objects:responsefunction:start|response function]]. It is evaluated at the energies of the plot range, from //"Xmin"// to //"Xmax"// of the //"Frame"//, by default from -1 to 1. A matrix valued (block) response function is drawn as a grid of panels, one for each matrix element. |
| * //GammaL// : (optional) Real, the Lorentzian broadening of //G// (full width at half maximum). Default value 0 | * //GammaL// : (optional) Real, the Lorentzian broadening of //G// (full width at half maximum). Default value 0 |
| * //GammaG// : (optional) Real, the Gaussian broadening of //G// (full width at half maximum). Default value 0 | * //GammaG// : (optional) Real, the Gaussian broadening of //G// (full width at half maximum). Default value 0 |
| * //NE// : (optional) Integer, the number of energies at which //G// is evaluated. Default value $1 + 10 (X_{max} - X_{min}) / \Gamma$, with $\Gamma$ = //GammaL//, or //GammaG// when //GammaL// is 0, and //"PlotPoints"// when both are 0 | * //NE// : (optional) Integer, the number of intervals of the energy mesh: //G// is evaluated at //NE// + 1 equally spaced energies. Default value $1 + 10 (X_{max} - X_{min}) / \Gamma$, with $\Gamma$ = //GammaL//, or //GammaG// when //GammaL// is 0, and //"PlotPoints"// when both are 0 |
| * Options : A table of options. Possible options are: | * Options : A table of options. Possible options are: |
| * //"Frame"// : a table of options for the frame and the axes, see [[#the_frame|The frame]] below. //"Axis"// is the same option. | * //"Frame"// : a table of options for the frame and the axes, see [[#the_frame|The frame]] below. //"Axis"// is the same option. |
| * //"Scale"// : Real, the values are multiplied by //"Scale"// before they are drawn. Default value 1 | * //"Scale"// : Real, the values are multiplied by //"Scale"// before they are drawn. Default value 1 |
| * //"LineStyle"// : a list of line styles, see [[#line_styles|Line styles]] below | * //"LineStyle"// : a list of line styles, see [[#line_styles|Line styles]] below |
| * //"LineStyleCycle"// : Integer, the curves of a list take the styles 1 to //"LineStyleCycle"// in turn. Default value: all styles | * //"LineStyleCycle"// : Integer, the curves of a list take the styles 1 to //"LineStyleCycle"// in turn. Default value: all styles <color #ed1c24>New in 0.9.1</color> |
| * //"PlotPoints"// : Integer, the number of energies at which the response functions in a list are evaluated. Default value 600 | * //"PlotPoints"// : Integer, the number of intervals of the equally spaced mesh on which response functions (unbroadened, or in a list) and interpolating functions are evaluated: //"PlotPoints"// + 1 points, for an interpolating function in addition to its own points. Default value 600, so 601 points |
| * //"WaterfallShift"// : Real, curve $n$ is shifted up by $(n-1)$ //"WaterfallShift"//. Default value 0 | * //"WaterfallShift"// : Real, curve $n$ is shifted up by $(n-1)$ //"WaterfallShift"//. Default value 0 |
| * //"WaterfallOffset"// : Real, all curves are shifted up by //"WaterfallOffset"//. Default value 0 | * //"WaterfallOffset"// : Real, all curves are shifted up by //"WaterfallOffset"//. Default value 0 |
| |
| ===== Line styles ===== | ===== Line styles ===== |
| | ;;# |
| | <color #ed1c24>Modified in 0.9.1</color> |
| | ;;# |
| |
| ### | ### |
| |
| ### | ### |
| | A line is drawn with as few points as it needs: a point is left out when it lies within 0.01 mm of the line through the points that are kept. This does not change the picture (SVG and PostScript files resolve 0.035 mm) and keeps the files small; the curve of an atomic orbital, evaluated at some 2000 points, needs a few dozen. The dots of //"PointSize"// are drawn at all points. |
| | |
| 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. | 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. |
| ### | ### |
| |
| ### | ### |
| 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. | 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 or interpolating functions, 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. |
| ### | ### |
| |
| |
| ===== Example ===== | ===== Example ===== |
| | ;;# |
| | <color #ed1c24>Modified in 0.9.1</color> |
| | ;;# |
| |
| ### | ### |
| ===== Table of contents ===== | ===== Table of contents ===== |
| {{indexmenu>../#2|tsort}} | {{indexmenu>../#2|tsort}} |
| | |
| |