Macro Language
Introduction
There are ~300 commands, ~55 math functions and ~190 constants available in the Plot macro language. Most of the commands need one or more argument. Simply enter the command followed by the arguments separated by spaces.
Special Characters:
: | Separator for multiple commands in one line |
; | Separator for arguments in functions (see Expressions) |
" | Quotes for arguments containing whitespaces |
' | Quotes for arguments containing whitespaces |
# | Escape character for comments. Starting from this character the rest of a line will be treated as comment |
For example a command may look like this:
atext xb "Axis Text"
clr : list : exit
This command sets the axis text label for the first (bottom) X axis.
Note: some macro commands does not fully work with the Plot2 version from the AppStore. Use the download version instead.
http://apps.micw.org/apps/plot2/downloads.php
There is also a syntax mode for Coda2 available: http://apps.micw.org/apps/plot2/downloads/Plot2-Daviz.mode.zip
Variables
During macro execution several variables are available. String variable starts with a $
sign.
cb | number of the current working buffer in the document |
$date | the current date |
$document | the filename of the current document |
dx1 | the distance between the last two measures with the mouse (1. X axis) |
dx2 | the distance between the last two measures with the mouse (2. X axis) |
dy1 | the distance between the last two measures with the mouse (1. Y axis) |
dy2 | the distance between the last two measures with the mouse (2. Y axis) |
$file | the filename from the browse command |
f[0-23][a-e] | the values from the curve fit parameter table, e.g: f2b |
fitsuccess | 1 if the last curve fit succeeded, 0 if not |
fititerations | the number of iterations in the last curve fit |
fitrmsd | RMSD from the last curve fit |
fitchi2 | Chi2 from the last fit curve |
fitsigma | Sigma from the last curve fit |
framebottom | the position of bottom frame line |
frameleft | the position of left frame line |
frameright | the position of right frame line |
frametop | the position of top frame line |
framewidth | the width of the frame |
frameheight | the hight of the frame |
framelinewidth | the width of the frame border lines |
$home | the users home directory |
input | the result of the last input command |
$input | the result of the last input command as string |
integral | the result from the last calcint command |
l | the run variable for loops |
lx | the X value during a data loop |
ly | the Y value during a data loop |
lxe | the X error value during a data loop |
lye | the X error value during a data loop |
lastbuffer | the number of the last buffer generated by one of the calculation commands |
marginbottom,mb | the bottom margin |
marginleft,ml | the left margin |
marginright,mr | the right margin |
margintop,mt | the top margin |
mt | the number of seconds from the absolute reference date (00:00:00 UTC on 1 January 2001) |
nb | number of data buffer in the document |
option | the result of the askoption command |
ref1 | the 1. reference value |
ref2 | the 2. reference value |
linbga , linbgb | the reference values for linear background subtraction |
rega , regb , regr | the result of the last regression |
textheight,th | the height of the last added text |
textwidth,tw | the width of the last added text |
$time | the current time with seconds |
$shorttime | the current time without seconds |
timercount | contains the number of timed macro executions |
$user | the user name |
ut | the number of seconds from the reference date (00:00:00 UTC on 1 January 1970), aka unix timestamp |
viewheight,h | the height of the current view |
viewwidth,w | the width of the current view |
windowheight,wh | the window height |
windowwidth,ww | the window width |
xmin1 | min value of the 1. (bottom) X axis |
xmin2 | min value of the 2. (top) X axis |
xmax1 | max value of the 1. (bottom) X axis |
xmax2 | max value of the 2. (top) X axis |
xpos1 | the last result of the measure with the mouse (1. X axis) |
xpos2 | the last result of the measure with the mouse (2. X axis) |
ymax1 | max value of the 1. (left) Y axis |
ymax2 | max value of the 2. (right) Y axis |
ymin1 | min value of the 1. (left) Y axis |
ymin2 | min value of the 2. (right) Y axis |
ypos1 | the last result of the measure with the mouse (1. Y axis) |
ypos2 | the last result of the measure with the mouse (2. Y axis) |
Arguments
In the command descriptions on the following pages optional argument is written with surround square brackets
([argument]
) and required arguments with angle brackets (<argument>
).
There are also some special arguments:
BOOL
this is a switch parameter which can only have two values.Possible values:
0, false, no, off | Switch Off |
1, true, yes, on | Switch On |
BUFFER
a list of one or more data buffers. Possible values are:
all | all buffers in the document |
selected | selected buffers in the document |
unselected | unselected buffers in the document |
visible | visible buffers in the document |
hidden | hidden buffers in the document |
none | no buffer |
b1,b2,b3,...,bn | a list of buffers where the arguments may be math expressions. |
bs..be | buffers from bs to be |
AXIS
Defines the axis to which the command apply. Possible values are:
all | all four axis |
x | both X axis |
y | both Y axis |
1, x1, xb, bottom | 1. X axis (bottom) |
2, y1, yl, left | 1. Y axis (left) |
3, x2, xt, top | 2. X axis (top) |
4, y2, yr, right | 2. Y axis (right) |
AXISGROUP
The coordinates system:
0, both | both axis |
1, first | first axis (left and bottom) |
2, second | second axis (right and top) |
NUMBERFORMAT
The axis number format:
0, sci | numbers with scientific notation |
1, eng | numbers with engineering notation |
2, si | numbers with SI notation |
COOR
The coordinates system:
0, screen | screen coordinates |
1, first | first axis (left and bottom) |
2, second | second axis (right and top) |
RANGE
A list of numbers (e.g. used for the loop
command):
n | defines a range from 0 to n |
from;to;step | defines a range where the arguments may be math expressions. |
b1,b2,b3,...,bn | a list of numbers where the arguments may be math expressions. |
bs..be | numbers from bs to be |
ALIGN
A parameter wich defines the alignment of different objects, possible values:
topleft | topcenter | topright |
centerleft | center | centerright |
bottomleft | bottomcenter | bottomright |
TEXTALIGN
A parameter wich defines the alignment of text elements:
left | center | right |
AUTOTEXTPOS
A parameter wich defines the alignment of different objects, possible values:
outsidetopleft | outsidetopcenter | outsidetopright | ||
outsidelefttop | topleft | topcenter | topright | outsiderighttop |
outsideleftcenter | centerleft | center | centerright | outsiderightcenter |
outsideleftbottom | bottomleft | bottomcenter | bottomright | outsiderightbottom |
outsidebottomleft | outsidebottomcenter | outsidebottomright |
COLOR
This can be a hexadecimal color definition in the format RGB, ARGB, RRGGBB or AARRGGBB where R is red, G is green, B is blue and A is alpha.
There are also named colors which can be used: black, white, red, green, blue, orange, yellow, magenta, cyan, aluminum, aqua, asparagus, banana, blueberry, bubblegum, cantaloupe, carnation, cayenne, clover, eggplant, fern, flora, grape, honeydew, ice, iron, lavender, lead, lemon, licorice, lime, magnesium, maraschino, maroon, mercury, midnight, mocha, moss, nickel, ocean, orchid, plum, salmon, seafoam, silver, sky, snow, spindrift, spring, steel, strawberry, tangerine, teal, tin, tungsten, turquoise
The Plot default colors can be addressed with the numbers 0-15
TIMEFORMAT
Plot stores time data as the number of seconds relative to an absolute reference time: the first instant of 1 January, 2001, Greenwich Mean Time (GMT). Dates before then are stored as negative numbers; dates after then are stored as positive numbers.
To convert a UNIX time to a Plot time simply subtract 978307200.0 from the UNIX time.
Time format tokens
Field | Sym. | No. | Example | Description | ||||||||||||||||||||||||||||||||||||
era | G | 1..3 | AD | Era - Replaced with the Era string for the current
date. One to three letters for the abbreviated form, four letters for the long form, five for the narrow form. |
||||||||||||||||||||||||||||||||||||
4 | Anno Domini | |||||||||||||||||||||||||||||||||||||||
5 | A | |||||||||||||||||||||||||||||||||||||||
year | y | 1..n | 1996 | Year. Normally the length specifies the padding, but for two letters it also specifies the maximum length.
Example:
|
||||||||||||||||||||||||||||||||||||
Y | 1..n | 1997 | Year (in "Week of Year" based calendars). Normally the length specifies the padding,
but for two letters it also specifies the maximum length. This year designation is used in ISO year-week calendar as defined by ISO 8601, but can be used in non-Gregorian based calendar systems where week date processing is desired. May not always be the same value as calendar year. |
|||||||||||||||||||||||||||||||||||||
u | 1..n | 4601 | Extended year. This is a single number designating the year of this calendar system, encompassing
all supra-year fields. For example, for the Julian calendar system, year numbers are positive, with an era of BCE or CE. An extended year value for the Julian calendar system assigns positive values to CE years and negative values to BCE years, with 1 BCE being year 0. |
|||||||||||||||||||||||||||||||||||||
U | 1..3 | 甲子 | Cyclic year name. Calendars such as the
Chinese lunar calendar (and related calendars) and the Hindu calendars use 60-year cycles of year names. Use one through three letters for the abbreviated name, four for the full name, or five for the narrow name (currently the data only provides abbreviated names, which will be used for all requested name widths). If the calendar does not provide cyclic year name data, or if the year value to be formatted is out of the range of years for which cyclic name data is provided, then numeric formatting is used (behaves like 'y'). |
|||||||||||||||||||||||||||||||||||||
4 | (currently also 甲子) | |||||||||||||||||||||||||||||||||||||||
5 | (currently also 甲子) | |||||||||||||||||||||||||||||||||||||||
quarter | Q | 1..2 | 02 | Quarter - Use one or two for the numerical
quarter, three for the abbreviation, or four for the full name. |
||||||||||||||||||||||||||||||||||||
3 | Q2 | |||||||||||||||||||||||||||||||||||||||
4 | 2nd quarter | |||||||||||||||||||||||||||||||||||||||
q | 1..2 | 02 | Stand-Alone Quarter - Use one or two
for the numerical quarter, three for the abbreviation, or four for the full name. |
|||||||||||||||||||||||||||||||||||||
3 | Q2 | |||||||||||||||||||||||||||||||||||||||
4 | 2nd quarter | |||||||||||||||||||||||||||||||||||||||
month | M | 1..2 | 09 | Month - Use one or two for the numerical
month, three for the abbreviation, four for the full name, or five for the narrow name. |
||||||||||||||||||||||||||||||||||||
3 | Sept | |||||||||||||||||||||||||||||||||||||||
4 | September | |||||||||||||||||||||||||||||||||||||||
5 | S | |||||||||||||||||||||||||||||||||||||||
L | 1..2 | 09 | Stand-Alone Month - Use one or two
for the numerical month, three for the abbreviation, or four for the full name, or 5 for the narrow name. |
|||||||||||||||||||||||||||||||||||||
3 | Sept | |||||||||||||||||||||||||||||||||||||||
4 | September | |||||||||||||||||||||||||||||||||||||||
5 | S | |||||||||||||||||||||||||||||||||||||||
l | 1 | (nothing) | This pattern character is deprecated, and should be ignored in patterns. It was originally intended
to be used in combination with M to indicate placement of the symbol for leap month in the Chinese calendar. Placement of that marker is now specified using locale-specific <monthPatterns> data, and formatting and parsing of that marker should be handled as part of supporting the regular M and L pattern characters. |
|||||||||||||||||||||||||||||||||||||
week | w | 1..2 | 27 | Week of Year. | ||||||||||||||||||||||||||||||||||||
W | 1 | 3 | Week of Month | |||||||||||||||||||||||||||||||||||||
day | d | 1..2 | 1 | Date - Day of the month | ||||||||||||||||||||||||||||||||||||
D | 1..3 | 345 | Day of year | |||||||||||||||||||||||||||||||||||||
F | 1 | 2 | Day of Week in Month. The example is for the 2nd Wed in July | |||||||||||||||||||||||||||||||||||||
g | 1..n | 2451334 | Modified Julian day. This is different from the conventional Julian day number in two regards.
First, it demarcates days at local zone midnight, rather than noon GMT. Second, it is a local number; that is, it depends on the local time zone. It can be thought of as a single number that encompasses all the date-related fields. |
|||||||||||||||||||||||||||||||||||||
week day |
E | 1..3 | Tues | Day of week - Use one through three letters
for the short day, or four for the full name, five for the narrow name, or six for the short name. |
||||||||||||||||||||||||||||||||||||
4 | Tuesday | |||||||||||||||||||||||||||||||||||||||
5 | T | |||||||||||||||||||||||||||||||||||||||
6 | Tu | |||||||||||||||||||||||||||||||||||||||
e | 1..2 | 2 | Local day of week. Same as E except adds
a numeric value that will depend on the local starting day of the week, using one or two letters. For this example, Monday is the first day of the week. |
|||||||||||||||||||||||||||||||||||||
3 | Tues | |||||||||||||||||||||||||||||||||||||||
4 | Tuesday | |||||||||||||||||||||||||||||||||||||||
5 | T | |||||||||||||||||||||||||||||||||||||||
6 | Tu | |||||||||||||||||||||||||||||||||||||||
c | 1 | 2 | Stand-Alone local day of week -
Use one letter for the local numeric value (same as 'e'), three for the short day, four for the full name, five for the narrow name, or six for the short name. |
|||||||||||||||||||||||||||||||||||||
3 | Tues | |||||||||||||||||||||||||||||||||||||||
4 | Tuesday | |||||||||||||||||||||||||||||||||||||||
5 | T | |||||||||||||||||||||||||||||||||||||||
6 | Tu | |||||||||||||||||||||||||||||||||||||||
period | a | 1 | AM | AM or PM | ||||||||||||||||||||||||||||||||||||
hour | h | 1..2 | 11 | Hour [1-12]. When used in skeleton data or in a skeleton passed in an API for flexible date
pattern generation, it should match the 12-hour-cycle format preferred by the locale (h or K); it should not match a 24-hour-cycle format (H or k). Use hh for zero padding. |
||||||||||||||||||||||||||||||||||||
H | 1..2 | 13 | Hour [0-23]. When used in skeleton data or in a skeleton passed in an API for flexible date
pattern generation, it should match the 24-hour-cycle format preferred by the locale (H or k); it should not match a 12-hour-cycle format (h or K). Use HH for zero padding. |
|||||||||||||||||||||||||||||||||||||
K | 1..2 | 0 | Hour [0-11]. When used in a skeleton, only matches K or h, see above. Use KK for zero padding. | |||||||||||||||||||||||||||||||||||||
k | 1..2 | 24 | Hour [1-24]. When used in a skeleton, only matches k or H, see above. Use kk for zero padding. | |||||||||||||||||||||||||||||||||||||
j | 1..2 | n/a | This is a special-purpose symbol. It must not occur in pattern or skeleton data. Instead, it
is reserved for use in skeletons passed to APIs doing flexible date pattern generation. In such a context, it requests the preferred hour format for the locale (h, H, K, or k), as determined by whether h, H, K, or k is used in the standard short time format for the locale. In the implementation of such an API, 'j' must be replaced by h, H, K, or k before beginning a match against availableFormats data. Note that use of 'j' in a skeleton passed to an API is the only way to have a skeleton request a locale's preferred time cycle type (12-hour or 24-hour). |
|||||||||||||||||||||||||||||||||||||
minute | m | 1..2 | 59 | Minute. Use one or two for zero padding. | ||||||||||||||||||||||||||||||||||||
second | s | 1..2 | 12 | Second. Use one or two for zero padding. | ||||||||||||||||||||||||||||||||||||
S | 1..n | 3456 | Fractional Second - truncates (like other time fields) to the count of letters.
(example shows display using pattern SSSS for seconds value 12.34567) |
|||||||||||||||||||||||||||||||||||||
A | 1..n | 69540000 | Milliseconds in day. This field behaves exactly like a composite of all time-related fields,
not including the zone fields. As such, it also reflects discontinuities of those fields on DST transition days. On a day of DST onset, it will jump forward. On a day of DST cessation, it will jump backward. This reflects the fact that is must be combined with the offset field to obtain a unique local time value. |
|||||||||||||||||||||||||||||||||||||
zone | z | 1..3 | PDT | The short specific non-location format.
Where that is unavailable, falls back to the short localized GMT format ("O"). |
||||||||||||||||||||||||||||||||||||
4 | Pacific Daylight Time | The long specific non-location format.
Where that is unavailable, falls back to the long localized GMT format ("OOOO"). |
||||||||||||||||||||||||||||||||||||||
Z | 1..3 | -0800 | The ISO8601 basic format with hours, minutes and optional seconds fields.
The format is equivalent to RFC 822 zone format (when optional seconds field is absent). This is equivalent to the "xxxx" specifier. |
|||||||||||||||||||||||||||||||||||||
4 | GMT-8:00 | The long localized GMT format.
This is equivalent to the "OOOO" specifier. |
||||||||||||||||||||||||||||||||||||||
5 | -08:00 -07:52:58 |
The ISO8601 extended format with hours, minutes and optional seconds fields.
The ISO8601 UTC indicator "Z" is used when local time offset is 0. This is equivalent to the "XXXXX" specifier. |
||||||||||||||||||||||||||||||||||||||
O | 1 | GMT-8 | The short localized GMT format. | |||||||||||||||||||||||||||||||||||||
4 | GMT-08:00 | The long localized GMT format. | ||||||||||||||||||||||||||||||||||||||
v | 1 | PT | The short generic non-location format.
Where that is unavailable, falls back to the generic location format ("VVVV"), then the short localized GMT format as the final fallback. |
|||||||||||||||||||||||||||||||||||||
4 | Pacific Time | The long generic non-location format.
Where that is unavailable, falls back to generic location format ("VVVV"). | ||||||||||||||||||||||||||||||||||||||
V | 1 | uslax | The short time zone ID.
Where that is unavailable, the special short time zone ID unk (Unknown Zone) is used. |
|||||||||||||||||||||||||||||||||||||
2 | America/Los_Angeles | The long time zone ID. | ||||||||||||||||||||||||||||||||||||||
3 | Los Angeles | The exemplar city (location) for the time zone.
Where that is unavailable, the localized exemplar city name for the special zone Etc/Unknown is used as the fallback (for example, "Unknown City"). |
||||||||||||||||||||||||||||||||||||||
4 | Los Angeles Time | The generic location format.
Where that is unavailable, falls back to the long localized GMT format ("OOOO";
Note: Fallback is only necessary with a GMT-style Time Zone ID, like Etc/GMT-830.) |
||||||||||||||||||||||||||||||||||||||
X | 1 | -08 +0530 |
The ISO8601 basic format with hours field and optional minutes field.
The ISO8601 UTC indicator "Z" is used when local time offset is 0. (The same as x, plus "Z".) |
|||||||||||||||||||||||||||||||||||||
2 | -0800 Z |
The ISO8601 basic format with hours and minutes fields.
The ISO8601 UTC indicator "Z" is used when local time offset is 0. (The same as xx, plus "Z".) |
||||||||||||||||||||||||||||||||||||||
3 | -08:00 Z |
The ISO8601 extended format with hours and minutes fields.
The ISO8601 UTC indicator "Z" is used when local time offset is 0. (The same as xxx, plus "Z".) |
||||||||||||||||||||||||||||||||||||||
4 | -0800 -075258 |
The ISO8601 basic format with hours, minutes and optional seconds fields.
The ISO8601 UTC indicator "Z" is used when local time offset is 0. (The same as xxxx, plus "Z".) |
||||||||||||||||||||||||||||||||||||||
5 | -08:00 -07:52:58 |
The ISO8601 extended format with hours, minutes and optional seconds fields.
The ISO8601 UTC indicator "Z" is used when local time offset is 0. (The same as xxxxx, plus "Z".) |
||||||||||||||||||||||||||||||||||||||
x | 1 | -08 +0530 |
The ISO8601 basic format with hours field and optional minutes field. (The same as X, minus "Z".) | |||||||||||||||||||||||||||||||||||||
2 | -0800 | The ISO8601 basic format with hours and minutes fields. (The same as XX, minus "Z".) | ||||||||||||||||||||||||||||||||||||||
3 | -08:00 | The ISO8601 extended format with hours and minutes fields. (The same as XXX, minus "Z".) | ||||||||||||||||||||||||||||||||||||||
4 | -0800 -075258 |
The ISO8601 basic format with hours, minutes and optional seconds fields. (The same as XXXX, minus "Z".) Note: The seconds field is not supported by the ISO8601 specification. |
||||||||||||||||||||||||||||||||||||||
5 | -08:00 -07:52:58 |
The ISO8601 extended format with hours, minutes and optional seconds fields. (The same as XXXXX, minus "Z".) Note: The seconds field is not supported by the ISO8601 specification. |
Old time format tokens
This is only used if your time format contains at least one %. You should not use this syntax, it is only available for compatibility with older files
%a | Abbreviated weekday name |
%A | Full weekday name |
%b | Abbreviated month name |
%B | Full month name |
%c | Shorthand for “x", the locale format for date and time |
%d | Day of the month as a decimal number (01-31) |
%e | Same as %d but does not print the leading 0 for days 1 through 9 (unlike strftime(), does not print a leading space) |
%F | Milliseconds as a decimal number (000-999) |
%H | Hour based on a 24-hour clock as a decimal number (00-23) |
%I | Hour based on a 12-hour clock as a decimal number (01-12) |
%j | Day of the year as a decimal number (001-366) |
%m | Month as a decimal number (01-12) |
%M | Minute as a decimal number (00-59) |
%p | AM/PM designation for the locale |
%S | Second as a decimal number (00-59) |
%w | Weekday as a decimal number (0-6), where Sunday is 0 |
%x | Date using the date representation for the locale, including the time zone (produces different results from strftime()) |
%X | Time using the time representation for the locale (produces different results from strftime()) |
%y | Year without century (00-99) |
%Y | Year with century (such as 1990) |
%Z | Time zone name (such as Pacific Daylight Time; produces different results from strftime()) |
%z | Time zone offset in hours and minutes from GMT (HHMM) |