Compute the mean for a variable using Python.
- It is assumed that Python and any needed Python packages
(e.g., numpy) are already installed on the local platform.
This specific command does not require any additional Python
- The Python script, mean.py, that computes the mean is stored in
the "scripts" subdirectory of the Dataplot auxiliary files.
The default Linux/Unix location is "/usr/local/lib/dataplot" and
the default Windows location is
"C:\Program Files (x86)\NIST\DATAPLOT". However, the location on
your local platform may vary.
- The values for the variable for which the mean is to be computed
are written to the file "dpst1f.dat" in the current directory.
- The following command is executed
SYSTEM python <path>script/mean.py > dpst2f.dat
with <path> denoting the the location of the Dataplot
auxiliary files. The file "dpst2f.dat" will contain the
computed mean value.
- The computed mean will be saved in a user specified Dataplot
This initial PYTHON command was designed to create the basic structure
for incorporating Python-based commands into Dataplot. It is
anticipated that additional non-trivial Python-based commands will be
added in subsequent Dataplot releases.
LET <par> = PYTHON MEAN <y>
where <y> is the response variable;
<par> is a parameter where the computed mean is
and where the <SUBSET/EXCEPT/FOR qualification> is optional.
LET A = PYTHON MEAN Y1
LET A = PYTHON MEAN Y1 SUBSET TAG > 2
Both Python 2 and Python 3 are currently actively supported. If both
Python 2 and Python 3 are installed on your local platform, you can
use the following command to specify which version to run
SET PYTHON VERSION <2/3/DEFAULT>
Specifying "2" will run "python2", specifying "3" will run "python3"
and specifying "DEFAULT" will run "python" (i.e., the default on your
The Dataplot written scripts will be written to the Python 3
standard. However, if you only have Python 2 on your system, you can
modify the "mean.py" script to be compatible with Python 2 (for this
command, only the "print" commands should need to be changed). We do
not anticipate providing both Python 2 and Python 3 versions of the
You can use the CAPTURE
SCRIPT command to create Python scripts from within a Dataplot
macro. You can then use the SYSTEM command to execute that script.
That is, something like
CAPTURE SCRIPT file.py
... Python commands here ...
END OF CAPTURE
Compute the mean of a variable.
Execute an operating system command.
READ ZARR13.DAT Y
LET YMEAN = PYTHON MEAN Y
NIST is an agency of the U.S.
Date created: 02/27/2019
Last updated: 02/27/2019
Please email comments on this WWW page to