1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532
|
================================================
Veusz command line and embedding interface (API)
================================================
.. _Commands:
Introduction
############
Veusz uses a common API, or set of commands, to control the program
via its command line (from the Veusz console; click View, Windows,
Console Window), the embedding interface (when Veusz is embedded in
other Python programs), from within plugins, within documents (VSZ
documents contain commands used to generate the document) or
externally from the operating system command line (using `veusz
--listen`).
As Veusz is a a Python application it uses Python as its scripting
language. You can therefore freely mix Veusz and Python commands on
the Veusz command line (Click View, Windows, Console Window to get
access to the command line). Veusz can also read in Python scripts
from files on the command line (see the :ref:`Load <Command.Load>`
command).
When commands are entered in the command prompt in the Veusz window,
Veusz supports a simplified command syntax, whereq brackets following
commands names, and commas, can replaced by spaces in Veusz commands
(not Python commands). For example, :command:`Add('graph',
name='foo')`, may be entered as :command:`Add 'graph' name='foo'`.
The :command:`numpy` package is already imported into the command line
interface (as `\*`), so you do not need to import it first.
The command prompt supports history (use the up and down cursor keys
to recall previous commands).
Most of the commands listed below can be used in the in-program
command line interface, using the embedding interface or using `veusz
--listen`. Commands specific to particular modes are documented as
such.
Veusz also includes a new object-oriented version of the API, which is
documented at new_api_.
Commands and API
################
We list the allowed set of commands below
Action
------
.. _Command.Action:
:command:`Action('actionname',
componentpath='.')`
Initiates the specified action on the widget (component)
given the action name. Actions perform certain automated
routines. These include "fit" on a fit widget, and
"zeroMargins" on grids.
Add
---
.. _Command.Add:
:command:`Add('widgettype', name='nameforwidget',
autoadd=True, optionalargs)`
The Add command adds a graph into the current widget (See the :ref:`To
<Command.To>` command to change the current position).
The first argument is the type of widget to add. These include
"graph", "page", "axis", "xy" and "grid". :command:`name` is the name
of the new widget (if not given, it will be generated from the type of
the widget plus a number). The :command:`autoadd` parameter if set,
constructs the default sub-widgets this widget has (for example, axes
in a graph).
Optionally, default values for the graph settings may be given, for
example :command:`Add('axis', name='y', direction='vertical')`.
Subsettings may be set by using double underscores, for example
:command:`Add('xy', MarkerFill__color='red',
ErrorBarLine__hide=True)`.
Returns: Name of widget added.
AddCustom
---------
.. _Command.AddCustom:
:command:`AddCustom(type, name, value)`
Add a custom definition for evaluation of expressions. This can define
a constant (can be in terms of other constants), a function of 1 or
more variables, or a function imported from an external python module.
ctype is "constant", "function" or "import".
name is name of constant, or "function(x, y, ...)" or module name.
val is definition for constant or function (both are _strings_), or is
a list of symbols for a module (comma separated items in a string).
If mode is 'appendalways', the custom value is appended to the end of
the list even if there is one with the same name. If mode is
'replace', it replaces any existing definition in the same place in
the list or is appended otherwise. If mode is 'append', then an
existing definition is deleted, and the new one appended to the end.
AddImportPath
-------------
.. _Command.AddImportPath:
:command:`AddImportPath(directory)`
Add a directory to the list of directories to try to import data from.
CloneWidget
-----------
.. _Command.CloneWidget:
:command:`CloneWidget(widget, newparent,
newname=None)`
Clone the widget given, placing the copy in newparent and the name
given. newname is an optional new name to give it Returns new widget
path.
Close
-----
.. _Command.Close:
:command:`Close()`
Closes the plotwindow. This is only supported in embedded mode.
CreateHistogram
---------------
.. _Command.CreateHistogram:
:command:`CreateHistogram(inexpr, outbinsds,
outvalsds, binparams=None, binmanual=None,
method='counts', cumulative = 'none',
errors=False)`
Histogram an input expression. inexpr is input expression. outbinds
is the name of the dataset to create giving bin positions. outvalsds
is name of dataset for bin values. binparams is None or (numbins,
minval, maxval, islogbins). binmanual is None or a list of bin
values. method is 'counts', 'density', or 'fractions'. cumulative is
to calculate cumulative distributions which is 'none', 'smalltolarge'
or 'largetosmall'. errors is to calculate Poisson error bars.
CurrentPath
-----------
.. _Command.CurrentPath:
:command:`CurrentPath()`
Returns current widget path, as set by :ref:`To<Command.To>`.
DatasetPlugin
-------------
.. _Command.DatasetPlugin:
:command:`DatasetPlugin(pluginname, fields,
datasetnames={})>`
Use a dataset plugin. pluginname: name of plugin to use fields: dict
of input values to plugin datasetnames: dict mapping old names to new
names of datasets if they are renamed. The new name None means dataset
is deleted
EnableToolbar
-------------
.. _Command.EnableToolbar:
:command:`EnableToolbar(enable=True)`
Enable/disable the zooming toolbar in the plotwindow. This command is
only supported in embedded mode or from `veusz --listen`.
Export
------
.. _Command.Export:
:command:`Export(filename, color=True, page=0, dpi=100,
antialias=True, quality=85, backcolor='#ffffff00', pdfdpi=150,
svgdpi=96, svgtextastext=False)`
Export the page given to the filename given. The :command:`filename`
must end with the correct extension to get the right sort of output
file. Currrenly supported extensions are '.eps', '.pdf', '.ps',
'.svg', '.jpg', '.jpeg', '.bmp' and '.png'. If :command:`color` is
True, then the output is in colour, else greyscale. :command:`page` is
the page number of the document to export (starting from 0 for the
first page!). A list of pages can be given for multipage formats (.pdf
or .ps). :command:`dpi` is the number of dots per inch for bitmap
output files. :command:`antialias` - antialiases output if
True. :command:`quality` is a quality parameter for jpeg
output. :command:`backcolor` is the background color for bitmap files,
which is a name or a #RRGGBBAA value (red, green, blue,
alpha). :command:`pdfdpi` is the dpi to use when exporting EPS or PDF
files. :command:`svgdpi` is the dpi to use when exporting to SVG files.
:command:`svgtextastext` says whether to export SVG text as
text, rather than curves.
FilterDatasets
--------------
.. _Command.FilterDatasets:
:command:`FilterDatasets(filterexpr, datasets, prefix="", suffix="",
invert=False, replaceblanks=False)`
Filter a list of datasets given. Creates new datasets for each with
prefix and suffix added to input dataset names. filterexpr is an input
numpy eexpression for filtering the datasets. If invert is set, the
filter condition is inverted. If replaceblanks is set, filtered values
are not removed, but replaced with a blank or NaN value. This command
only works on 1D numeric, date or text datasets.
ForceUpdate
-----------
.. _Command.ForceUpdate:
:command:`ForceUpdate()`
Force the window to be updated to reflect the current state of the
document. Often used when periodic updates have been disabled (see
SetUpdateInterval). This command is only supported in embedded mode or
from `veusz --listen`.
Get
---
.. _Command.Get:
:command:`Get('settingpath')`
Returns: The value of the setting given by the path.
.. code-block:: python
>>> Get('/page1/graph1/x/min')
'Auto'
GetChildren
-----------
.. _Command.GetChildren:
:command:`GetChildren(where='.')`
Returns: The names of the widgets which are children of
the path given
GetClick
--------
.. _Command.GetClick:
:command:`GetClick()`
Waits for the user to click on a graph and returns the
position of the click on appropriate axes. Command only works
in embedded mode.
Returns: A list containing tuples of the form (axispath,
val) for each axis for which the click was in range. The value
is the value on the axis for the click.
GetColormap
-----------
.. _Command.GetColormap:
:command:`GetColormap(name, invert=False, nvals=256)`
Returns a colormap as a numpy array of red, green, blue, alpha values
(ranging from 0 to 255) with the number of steps given.
GetData
-------
.. _Command.GetData:
:command:`GetData(name)`
Returns: For a 1D dataset, a tuple containing the dataset with the
name given. The value is (data, symerr, negerr, poserr), with each a
numpy array of the same size or None. data are the values of the
dataset, symerr are the symmetric errors (if set), negerr and poserr
and negative and positive asymmetric errors (if set). If a text
dataset, return a list of text elements. If the dataset is a date-time
dataset, return a list of Python datetime objects. If the dataset is a
2D dataset return the tuple (data, rangex, rangey), where data is a 2D
numpy array and rangex/y are tuples giving the range of the x and y
coordinates of the data. If it is an ND dataset, return an
n-dimensional array.
.. code-block:: python
data = GetData('x')
SetData('x', data[0]*0.1, \*data[1:])
GetDataType
-----------
.. _Command.GetDataType:
:command:`GetDataType(name)`
Get type of dataset with name given. Returns '1d' for a
1d dataset, '2d' for a 2d dataset, 'text' for a text dataset
and 'datetime' for a datetime dataset.
GetDatasets
-----------
.. _Command.GetDatasets:
:command:`GetDatasets()`
Returns: The names of the datasets in the current document.
GPL
---
.. _Command.GPL:
:command:`GPL()`
Print out the GNU Public Licence, which Veusz is licenced under.
ImportFile
----------
.. _Command.ImportFile:
:command:`ImportFile(comm, filename, descriptor, useblocks=False, linked=False, prefix='', suffix='', ignoretext=False, encoding='utf_8', renames=None)`
Imports data from a file. The arguments are the filename to load data
from and the descriptor.
The format of the descriptor is a list of variable names representing
the columns of the data. For more information see :ref:`Descriptors
<Descriptors>`.
If the linked parameter is set to True, if the document is saved, the
data imported will not be saved with the document, but will be reread
from the filename given the next time the document is opened. The
linked parameter is optional.
If useblocks is set, then blank lines or the word 'no' are used to
split the data into blocks. Dataset names are appended with an
underscore and the block number (starting from 1). encoding is the
name of the text file encoding. renames is a dict mapping existing to
new names after import.
If prefix and/or suffix are set, then the prefix and suffix are added
to each dataset name. If set, renames maps imported dataset names to
final dataset names after import.
Returns: A tuple containing a list of the imported datasets and the
number of conversions which failed for a dataset.
ImportFile2D
------------
.. _Command.ImportFile2D:
:command:`ImportFile2D(filename, datasetnames, xrange=None, yrange=None, invertrows=None, invertcols=None, transpose=None, gridatedge=None, mode='text', csvdelimiter=',', csvtextdelimiter='"', csvlocale='en_US', prefix="", suffix="", encoding='utf_8', linked=False)`
Imports two-dimensional data from a file. The required arguments are
the filename to load data from and the dataset name, or a list of
names to use.
In text mode, the file format this command accepts is a
two-dimensional matrix of numbers, with the columns separated by
spaces or tabs, and the rows separated by new lines. The X-coordinate
is taken to be in the direction of the columns. Comments are supported
(use `#`, `!` or `%`), as are continuation characters (`\\`). Separate
datasets are deliminated by using blank lines. In csv mode, the csv
parameters give the type of CSV file sypported.
::
xrange is a tuple containing the range of data in x coordinates
yrange is a tuple containing the range of data in y coordinates
if invertrows=True, then rows are inverted when read
if invertcols=True, then cols are inverted when read
if transpose=True, then rows and columns are swapped
if gridatedge=True, use top row and left column for pixel positions
mode is either 'text' or 'csv'
csvdelimiter is the csv delimiter for csv
csvtextdelimiter is the csv text delimiter for csv
csvlocale is locale to use when reading csv data
prefix and suffix are prepended and appended to dataset names
encoding is encoding character set
if linked=True then the dataset is linked to the file
Returns: list of imported datasets
In addition to the matrix of numbers, the various optional parameters
this command takes can also be specified in the data file. These
commands should be given on separate lines before the matrix of
numbers. They are:
#. xrange A B
#. yrange C D
#. invertrows
#. invertcols
#. transpose
ImportFileCSV
-------------
.. _Command.ImportFileCSV:
:command:`ImportFileCSV('filename', readrows=False,
delimiter=',', skipwhitespace=False, textdelimiter='"',
encoding='utf_8',
headerignore=0, rowsignore=0,
blanksaredata=False,
numericlocale='en_US',
dateformat='YYYY-MM-DD|T|hh:mm:ss',
headermode='multi',
dsprefix='', dssuffix='', prefix=None,
renames=None,
linked=False)`
This command imports data from a CSV format file. Data are read from
the file using the dataset names given at the top of the files in
columns. Please see the reading data section of this manual for more
information. The options are explained below.
::
readrows: if true, data are read across rather than down
delimiter: character for delimiting data (usually ',')
skipwhitespace: if true, white space following delimiter is ignored
textdelimiter: character surrounding text (usually '"')
encoding: encoding used in file
headerignore: number of lines to ignore after header text
rowsignore: number of rows to ignore at top of file
blanksaredata: treats blank lines in csv files as blank data values
numericlocale: format to use for reading numbers
dateformat: format for interpreting dates
headermode: 'multi': multiple headers allowed in file
'1st': first text found are headers
'none': no headers, guess data and use default names
Dataset names are prepended and appended, by dsprefix and dssuffix,
respectively
(prefix is backware compatibility only, it adds an underscore
relative to dsprefix)
renames is a map of old names to new names to rename on import
If linked is True the data are linked with the file.
Returns: list of imported datasets
ImportFileFITS
--------------
.. _Command.ImportFileFITS:
:command:`ImportFileFits(filename, items, namemap={},
slices={}, twodranges={}, twod_as_oned=set(\[]),
wcsmodes={}, prefix='', suffix='', renames={},
linked=False)`
Import data from a FITS file.
items is a list of datasets to be imported. items are formatted like
the following:
::
'/': import whole file
'/hduname': import whole HDU (image or table)
'/hduname/column': import column from table HDU
all values in items should be lower case.
HDU names have to follow a Veusz-specific naming. If the HDU has a
standard name (e.g. primary or events), then this is used. If the
HDU has a EXTVER keyword then this number is appended to this
name. An extra number is appended if this name is not unique. If
the HDU has no name, then the name used should be 'hduX', where X
is the HDU number (0 is the primary HDU).
namemap maps an input dataset (using the scheme above for items)
to a Veusz dataset name. Special suffixes can be used on the Veusz
dataset name to indicate that the dataset should be imported
specially.
::
'foo (+)': import as +ve error for dataset foo
'foo (-)': import as -ve error for dataset foo
'foo (+-)': import as symmetric error for dataset foo
slices is an optional dict specifying slices to be selected when
importing. For each dataset to be sliced, provide a tuple of
values, one for each dimension. The values should be a single
integer to select that index, or a tuple (start, stop, step),
where the entries are integers or None.
twodranges is an optional dict giving data ranges for 2D
datasets. It maps names to (minx, miny, maxx, maxy).
twod_as_oned: optional set containing 2D datasets to attempt to
read as 1D, treating extra columns as error bars
wcsmodes is an optional dict specfying the WCS import mode for 2D
datasets in HDUs. The keys are '/hduname' and the values can be
'pixel': number pixel range from 0 to maximum (default)
'pixel_wcs': pixel number relative to WCS reference pixel
'linear_wcs': linear coordinate system from the WCS keywords
'fraction': fractional values from 0 to 1.
renames is an optional dict mapping old to new dataset names, to
be renamed after importing
linked specifies that the dataset is linked to the file.
Values under the VEUSZ header keyword can be used to override defaults:
::
'name': override name for dataset
'slice': slice on importing (use format "start:stop:step,...")
'range': should be 4 item array to specify x and y ranges:
[minx, miny, maxx, maxy]
'xrange' / 'yrange': individual ranges for x and y
'xcent' / 'ycent': arrays giving the centres of pixels
'xedge' / 'yedge': arrays giving the edges of pixels
'twod_as_oned': treat 2d dataset as 1d dataset with errors
'wcsmode': use specific WCS mode for dataset (see values above)
These are specified under the VEUSZ header keyword in the form
KEY=VALUE
or for column-specific values
COLUMNNAME: KEY=VALUE
Returns: list of imported datasets
ImportFileHDF5
--------------
.. _Command.ImportFileHDF5:
:command:`ImportFileHDF5(filename, items, namemap={},
slices={}, twodranges={}, twod_as_oned=set(\[]),
convert_datetime={}, prefix='', suffix='', renames={},
linked=False)`
Import data from a HDF5 file. items is a list of groups and
datasets which can be imported. If a group is imported, all
child datasets are imported. namemap maps an input dataset
to a veusz dataset name. Special suffixes can be used on the
veusz dataset name to indicate that the dataset should be
imported specially.
::
'foo (+)': import as +ve error for dataset foo
'foo (-)': import as -ve error for dataset foo
'foo (+-)': import as symmetric error for dataset foo
slices is an optional dict specifying slices to be selected when
importing. For each dataset to be sliced, provide a tuple of values,
one for each dimension. The values should be a single integer to
select that index, or a tuple (start, stop, step), where the entries
are integers or None.
twodranges is an optional dict giving data ranges for 2d datasets. It
maps names to (minx, miny, maxx, maxy). twod_as_oned: optional set
containing 2d datasets to attempt to read as 1d
convert_datetime should be a dict mapping hdf name to specify
date/time importing. For a 1d numeric dataset: if this is set to
'veusz', this is the number of seconds since 2009-01-01, if this is
set to 'unix', this is the number of seconds since 1970-01-01. For a
text dataset, this should give the format of the date/time,
e.g. 'YYYY-MM-DD|T|hh:mm:ss' or 'iso' for iso format.
renames is a dict mapping old to new dataset names, to be renamed
after importing. linked specifies that the dataset is linked to the
file.
Attributes can be used in datasets to override defaults:
::
'vsz_name': set to override name for dataset in veusz
'vsz_slice': slice on importing (use format "start:stop:step,...")
'vsz_range': should be 4 item array to specify x and y ranges:
[minx, miny, maxx, maxy]
'vsz_twod_as_oned': treat 2d dataset as 1d dataset with errors
'vsz_convert_datetime': treat as date/time, set to one of the values
above.
For compound datasets these attributes can be given on a per-column
basis using attribute names vsz_attributename_columnname.
Returns: list of imported datasets
ImportFileND
------------
.. _Command.ImportFileND:
:command:`def ImportFileND(comm, filename, dataset, shape=None,
transpose=False, mode='text', csvdelimiter=',', csvtextdelimiter='"',
csvlocale='en_US', prefix="", suffix="", encoding='utf_8',
linked=False)`
Import an n-dimensional dataset from a file. The file should either be
in CSV format (mode='csv') or whitespace-separated text (mode='text').
A one-dimensional dataset is given as a list of numbers on a single
line/row. A two-dimensional dataset is given by a set of rows. A
three-dimensional dataset is given by a set of two-dimensional
datasets, with blank lines between them. a four-dimensional dataset is
given by a set of three-dimensional datasets with two blank lines
between each. Each additional dataset increases the separating number
of blank lines by one. Alternatively, the numbers can be given in any
form (number of numbers on each row) and "shape" is included to
reshape the data into the desired shape.
In the file, or included as parameters above, the command "shape num1
num2..." can be included to reshape the output dataset to the shape
given by the numbers in the row after "shape" (these should be in
separate columns in CSV format). If one of these numbers is -1, then
this dimension is inferred from the number of values and the other
dimensions. Also supported is the "transpose" command or optional
argument which reverses the order of the dimensions.
ImportFilePlugin
----------------
.. _Command.ImportFilePlugin:
:command:`ImportFilePlugin('pluginname', 'filename', \**pluginargs,
linked=False, encoding='utf_8', prefix='', suffix='', renames={})`
Import data from file using import plugin 'pluginname'. The arguments
to the plugin are given, plus optionally a text encoding, and prefix
and suffix to prepend or append to dataset names. renames, if set,
provides new names for datasets after import.
ImportFITSFile
--------------
.. _Command.ImportFITSFile:
:command:`ImportFITSFile(datasetname, filename, hdu, datacol='A',
symerrcol='B', poserrcol='C', negerrcol='D', linked=True/False,
renames={})`
This command is deprecated. Please do not use in new code, but instead
use ImportFileFITS.
This command does a simple import from a FITS file. The FITS format is
used within the astronomical community to transport binary data. For a
more powerful FITS interface, you can use PyFITS within your scripts.
The datasetname is the name of the dataset to import, the filename is
the name of the FITS file to import from. The hdu parameter specifies
the HDU to import data from (numerical or a name).
If the HDU specified is a primary HDU or image extension, then a
two-dimensional dataset is loaded from the file. The optional
parameters (other than linked) are ignored. Any WCS information within
the HDU are used to provide a suitable xrange and yrange.
If the HDU is a table, then the datacol parameter must be specified
(and optionally symerrcol, poserrcol and negerrcol). The dataset is
read in from the named column in the table. Any errors are read in
from the other specified columns.
If linked is True, then the dataset is not saved with a saved
document, but is reread from the data file each time the document is
loaded. renames, if set, provides new names for datasets after
import.
ImportString
------------
.. _Command.ImportString:
:command:`ImportString('descriptor',
'data')`
Like, :ref:`ImportFile <Command.ImportFile>`, but loads the data from
the specfied string rather than a file. This allows data to be easily
embedded within a document. The data string is usually a multi-line
Python string.
Returns: A tuple containing a list of the imported datasets and the
number of conversions which failed for a dataset.
Changed in version 0.5: A tuple is returned rather than just the
number of imported variables.
.. code-block:: python
ImportString('x y', '''
1 2
2 5
3 10
''')
ImportString2D
--------------
.. _Command.ImportString2D:
:command:`ImportString2D(datasets, string, xrange=None, yrange=None,
invertrows=None, invertcols=None, transpose=None)`
Imports a two-dimensional dataset from the string given. This is
similar to the :ref:`ImportFile2D <Command.ImportFile2D>` command,
with the same dataset format within the string. The optional values
are also listed there. The various controlling parameters can be set
within the string. See the :ref:`ImportFile2D <Command.ImportFile2D>`
section for details.
ImportStringND
--------------
.. _Command.ImportStringND:
:command:`ImportStringND(dataset, string, shape=None,
transpose=False)`
Imports a n-dimensional dataset from the string given. This is similar
to the :ref:`ImportFileND <Command.ImportFileND>` command. Please look
there for more detail and the description of the optional parameters
and in-stream allowed parameters.
IsClosed
--------
.. _Command.IsClosed:
:command:`IsClosed()`
Returns a boolean value telling the caller whether the plotting window
has been closed.
Note: this command is only supported in the embedding interface.
List
----
.. _Command.List:
:command:`List(where='.')`
List the widgets which are contained within the widget with the path
given, the type of widgets, and a brief description.
Load
----
.. _Command.Load:
:command:`Load('filename.vsz')`
Loads the veusz script file given. The script file can be any Python
code. The code is executed using the Veusz interpreter.
Note: this command is only supported at the command line and not in a
script. Scripts may use the python :command:`execfile` function
instead.
MoveToPage
----------
.. _Command.MoveToPage:
:command:`MoveToPage(pagenum)`
Updates window to show the page number given of the document.
Note: this command is only supported in the embedding interface or
`veusz --listen`.
ReloadData
----------
.. _Command.ReloadData:
:command:`ReloadData()`
Reload any datasets which have been linked to files.
Returns: A tuple containing a list of the imported datasets and the
number of conversions which failed for a dataset.
Rename
------
.. _Command.Rename:
:command:`Remove('widgetpath', 'newname')`
Rename the widget at the path given to a new name. This command does
not move widgets. See :ref:`To <Command.To>` for a description of the
path syntax. '.' can be used to select the current widget.
Remove
------
.. _Command.Remove:
:command:`Remove('widgetpath')`
Remove the widget selected using the path. See :ref:`To <Command.To>`
for a description of the path syntax.
ResizeWindow
------------
.. _Command.ResizeWindow:
:command:`ResizeWindow(width, height)`
Resizes window to be width by height pixels.
Note: this command is only supported in the embedding interface or
`veusz --listen`.
Save
----
.. _Command.Save:
:command:`Save('filename.vsz')`
Save the current document under the filename
given.
Set
---
.. _Command.Set:
:command:`Set('settingpath', val)`
Set the setting given by the path to the value given. If the type of
:command:`val` is incorrect, an :command:`InvalidType` exception is
thrown. The path to the setting is the optional path to the widget the
setting is contained within, an optional subsetting specifier, and the
setting itself.
.. code-block:: python
Set('page1/graph1/x/min', -10.)
SetAntiAliasing
---------------
.. _Command.SetAntiAliasing:
:command:`SetAntiAliasing(on)`
Enable or disable anti aliasing in the plot window, replotting the
image.
SetCompatLevel
--------------
.. _Command.SetCompatLevel:
:command:`SetCompatLevel(level)`
Set the document compatibility level. If `level<0`, then choose the latest version. As a side effect, this wipes any widgets in the document and resets all settings.
SetData
-------
.. _Command.SetData:
:command:`SetData(name, val, symerr=None, negerr=None, poserr=None)`
Set the dataset name with the values given. If None is given for an
item, it will be left blank. val is the actual data, symerr are the
symmetric errors, negerr and poserr and the getative and positive
asymmetric errors. The data can be given as lists or numpys.
SetDataExpression
-----------------
.. _Command.SetDataExpression:
:command:`SetDataExpression(name, val, symerr=None, negerr=None,
poserr=None, linked=False, parametric=None)`
Create a new dataset based on the expressions given. The expressions
are Python syntax expressions based on existing datasets.
If linked is True, the dataset will change as the datasets in the
expressions change.
Parametric can be set to a tuple of (minval, maxval,
numitems). :command:`t` in the expression will iterate from minval to
maxval in numitems values.
SetDataND
---------
.. _Command.SetDataND:
:command:`SetDataRange(name, val)`
Set a n-dimensional dataset to be the values given by val. val should
be an n-dimensional numpy array of values, or a list of lists.
SetDataRange
------------
.. _Command.SetDataRange:
:command:`SetDataRange(name, numsteps, val, symerr=None, negerr=None,
poserr=None, linked=False)`
Set dataset to be a range of values with numsteps steps. val is tuple
made up of (minimum value, maximum value). symerr, negerr and poserr
are optional tuples for the error bars.
If linked is True, the dataset can be saved in a document as a
SetDataRange, otherwise it is expanded to the values which would make
it up.
SetData2D
---------
.. _Command.SetData2D:
:command:`SetData2D('name', val, xrange=(A,B), yrange=(C,D),
xgrid=[1,2,3...], ygrid=[4,5,6...])`
Creates a two-dimensional dataset with the name given. val is either a
two-dimensional numpy array, or is a list of lists, with each list in
the list representing a row. Do not give xrange if xgrid is set and do
not give yrange if ygrid is set, and vice versa.
xrange and yrange are optional tuples giving the inclusive range of
the X and Y coordinates of the data. xgrid and ygrid are optional
lists, tuples or arrays which give the coordinates of the edges of the
pixels. There should be one more item in each array than pixels.
SetData2DExpression
-------------------
.. _Command.SetData2DExpression:
:command:`SetData2DExpression('name', expr, linked=False)`
Create a 2D dataset based on expressions. name is the new dataset
name expr is an expression which should return a 2D array linked
specifies whether to permanently link the dataset to the expressions.
SetData2DExpressionXYZ
----------------------
.. _Command.SetData2DExpressionXYZ:
:command:`SetData2DExpressionXYZ('name', 'xexpr', 'yexpr', 'zexpr',
linked=False)`
Create a 2D dataset based on three 1D expressions. The x, y
expressions need to evaluate to a grid of x, y points, with the z
expression as the 2D value at that point. Currently only linear fixed
grids are supported. This function is intended to convert calculations
or measurements at fixed points into a 2D dataset easily. Missing
values are filled with NaN.
SetData2DXYFunc
---------------
.. _Command.SetData2DXYFunc:
:command:`SetData2DXYFunc('name', xstep, ystep, 'expr', linked=False)`
Construct a 2D dataset using a mathematical expression of "x" and
"y". The x values are specified as (min, max, step) in xstep as a
tuple, the y values similarly. If linked remains as False, then a real
2D dataset is created, where values can be modified and the data are
stored in the saved file.
SetDataDateTime
---------------
.. _Command.SetDataDateTime:
:command:`SetDataDateTime('name', vals)`
Creates a datetime dataset of name given. vals is a list of Python
datetime objects.
SetDataText
-----------
.. _Command.SetDataText:
:command:`SetDataText(name, val)`
Set the text dataset name with the values given. :command:`val` must
be a type that can be converted into a Python list.
.. code-block:: python
SetDataText('mylabel', ['oranges', 'apples', 'pears', 'spam'])
SetToReference
--------------
.. _Command.SetToReference:
:command:`SetToReference(setting, refval)`
Link setting given to other setting refval.
SetUpdateInterval
-----------------
.. _Command.SetUpdateInterval:
:command:`SetUpdateInterval(interval)`
Tells window to update every interval milliseconds at most. The value
0 disables updates until this function is called with a non-zero. The
value -1 tells Veusz to update the window every time the document has
changed. This will make things slow if repeated changes are made to
the document. Disabling updates and using the ForceUpdate command will
allow the user to control updates directly.
Note: this command is only supported in the embedding interface or
`veusz --listen`.
SetVerbose
----------
.. _Command.SetVerbose:
:command:`SetVerbose(v=True)`
If :command:`v` is :command:`True`, then extra information is printed
out by commands.
StartSecondView
---------------
.. _Command.StartSecondView:
:command:`StartSecondView(name = 'window title')`
In the embedding interface, this method will open a new Embedding
interface onto the same document, returning the object. This new
window provides a second view onto the document. It can, for instance,
show a different page to the primary view. name is a window title for
the new window.
Note: this command is only supported in the embedding interface.
TagDatasets
-----------
.. _Command.TagDatasets:
:command:`TagDatasets('tag', ['ds1', 'ds2'...])`
Adds the tag to the list of datasets given..
To
--
.. _Command.To:
:command:`To('widgetpath')`
The To command takes a path to a widget and moves to that widget. For
example, this may be "/", the root widget, "graph1",
"/page1/graph1/x", "../x". The syntax is designed to mimic Unix paths
for files. "/" represents the base widget (where the pages reside),
and ".." represents the widget next up the tree.
Quit
----
.. _Command.Quit:
:command:`Quit()`
Quits Veusz. This is only supported in `veusz --listen`.
WaitForClose
------------
.. _Command.WaitForClose:
:command:`WaitForClose()`
Wait until the plotting window has been closed.
Note: this command is only supported in the embedding interface.
Zoom
----
.. _Command.Zoom:
:command:`Zoom(factor)`
Sets the plot zoom factor, relative to a 1:1 scaling. factor can also
be "width", "height" or "page", to zoom to the page width, height or
page, respectively.
This is only supported in embedded mode or `veusz --listen`.
Security
########
With the 1.0 release of Veusz, input scripts and expressions are
checked for possible security risks. Only a limited subset of Python
functionality is allowed, or a dialog box is opened allowing the user
to cancel the operation. Specifically you cannot import modules, get
attributes of Python objects, access globals() or locals() or do any
sort of file reading or manipulation. Basically anything which might
break in Veusz or modify a system is not supported. In addition
internal Veusz functions which can modify a system are also warned
against, specifically Print(), Save() and Export().
If you are running your own scripts and do not want to be bothered by
these dialogs, you can run veusz with the :command:`--unsafe-mode`
option.
Using Veusz from other programs
###############################
Non-Qt Python programs
----------------------
Veusz can be used as a Python module for plotting data. There are two
ways to use the module: (1) with an older path-based Veusz commands,
used in Veusz saved document files or (2) using an object-oriented
interface. With the old style method the user uses a unix-path
inspired API to navigate the widget tree and add or manipulate
widgets. With the new style interface, the user navigates the tree
with attributes of the ``Root`` object to access Nodes. The new
interface is likely to be easier to use unless you are directly
translating saved files.
Older path-based interface
--------------------------
.. code-block:: python
"""An example embedding program. Veusz needs to be installed into
the Python path for this to work (use setup.py)
This animates a sin plot, then finishes
"""
import time
import numpy
import veusz.embed as veusz
# construct a Veusz embedded window
# many of these can be opened at any time
g = veusz.Embedded('window title')
g.EnableToolbar()
# construct the plot
g.To( g.Add('page') )
g.To( g.Add('graph') )
g.Add('xy', marker='tiehorz', MarkerFill__color='green')
# this stops intelligent axis extending
g.Set('x/autoExtend', False)
g.Set('x/autoExtendZero', False)
# zoom out
g.Zoom(0.8)
# loop, changing the values of the x and y datasets
for i in range(10):
x = numpy.arange(0+i/2., 7.+i/2., 0.05)
y = numpy.sin(x)
g.SetData('x', x)
g.SetData('y', y)
# wait to animate the graph
time.sleep(2)
# let the user see the final result
print "Waiting for 10 seconds"
time.sleep(10)
print "Done!"
# close the window (this is not strictly necessary)
g.Close()
The embed interface has the methods listed in the command line
interface listed in the Veusz manual
https://veusz.github.io/docs/manual.html
Multiple Windows are supported by creating more than one ``Embedded``
object. Other useful methods include:
- ``WaitForClose()`` - wait until window has closed
- ``GetClick()`` - return a list of ``(axis, value)`` tuples where the
user clicks on a graph
- ``ResizeWndow(width, height)`` - resize window to be ``width`` x
``height`` pixels
- ``SetUpdateInterval(interval)`` - set update interval in ms or 0 to
disable
- ``MoveToPage(page)`` - display page given (starting from 1)
- ``IsClosed()`` - has the page been closed
- ``Zoom(factor)`` - set zoom level (float) or 'page', 'width',
'height'
- ``Close()`` - close window
- ``SetAntiAliasing(enable)`` - enable or disable antialiasing
- ``EnableToolbar(enable=True)`` - enable plot toolbar
- ``StartSecondView(name='Veusz')`` - start a second view onto the
document of the current ``Embedded`` object. Returns a new
``Embedded`` object.
- ``Wipe()`` - wipe the document of all widgets and datasets.
.. _new_api:
New-style object interface
--------------------------
In Veusz 1.9 or late a new style of object interface is present, which
makes it easier to construct the widget tree. Each widget, group of
settings or setting is stored as a Node object, or its subclass, in a
tree. The root document widget can be accessed with the ``Root``
object. The dot operator "." finds children inside other nodes. In
Veusz some widgets can contain other widgets (Root, pages, graphs,
grids). Widgets contain setting nodes, accessed as attributes. Widgets
can also contain groups of settings, again accessed as attributes.
An example tree for a document (not complete) might look like this
::
Root
\-- page1 (page widget)
\-- graph1 (graph widget)
\-- x (axis widget)
\-- y (axis widget)
\-- function (function widget)
\-- grid1 (grid widget)
\-- graph2 (graph widget)
\-- xy1 (xy widget)
\-- xData (setting)
\-- yData (setting)
\-- PlotLine (setting group)
\-- width (setting)
...
...
\-- x (axis widget)
\-- y (axis widget)
\-- graph3 (graph widget)
\-- contour1 (contour widget)
\-- x (axis widget)
\-- y (axis widget)
Here the user could access the xData setting node of the
xy1 widget using ``Root.page1.graph2.xy1.xData``. To
actually read or modify the value of a setting, you should get
or set the ``val`` property of the setting node. The line
width could be changed like this
.. code-block:: python
graph = embed.Root.page1.graph2
graph.xy1.PlotLine.width.val = '2pt'
For instance, this constructs a simple x-squared plot which
changes to x-cubed:
.. code-block:: python
import veusz.embed as veusz
import time
# open a new window and return a new Embedded object
embed = veusz.Embedded('window title')
# make a new page, but adding a page widget to the root widget
page = embed.Root.Add('page')
# add a new graph widget to the page
graph = page.Add('graph')
# add a function widget to the graph. The Add() method can take a list of settings
# to set after widget creation. Here, "function='x**2'" is equivalent to
# function.function.val = 'x**2'
function = graph.Add('function', function='x**2')
time.sleep(2)
function.function.val = 'x**3'
# this is the same if the widgets have the default names
Root.page1.graph1.function1.function.val = 'x**3'
If the document contains a page called "page1" then ``Root.page1`` is
the object representing the page. Similarly, ``Root.page1.graph1`` is
a graph called ``graph1`` in the page. You can also use
dictionary-style indexing to get child widgets,
e.g. Root['page1']['graph1']. This style is easier to use if the names
of widgets contain spaces or if widget names shadow methods or
properties of the Node object, i.e. if you do not control the widget
names.
Widget nodes can contain as children other widgets, groups of
settings, or settings. Groups of settings can contain child
settings. Settings cannot contain other nodes. Here are the useful
operations of Nodes:
.. code-block:: python
class Node(object):
"""properties:
path - return path to object in document, e.g. /page1/graph1/function1
type - type of node: "widget", "settinggroup" or "setting"
name - name of this node, e.g. "graph1"
children - a generator to return all the child Nodes of this Node, e.g.
for c in Root.children:
print c.path
children_widgets - generator to return child widget Nodes of this Node
children_settinggroups - generator for child setting groups of this Node
children_settings - a generator to get the child settings
childnames - return a list of the names of the children of this Node
childnames_widgets - return a list of the names of the child widgets
childnames_settinggroups - return a list of the names of the setting groups
childnames_settings - return a list of the names of the settings
parent - return the Node corresponding to the parent widget of this Node
__getattr__ - get a child Node with name given, e.g. Root.page1
__getitem__ - get a child Node with name given, e.g. Root['page1']
"""
def fromPath(self, path):
"""Returns a new Node corresponding to the path given, e.g. '/page1/graph1'"""
class SettingNode(Node):
"""A node which corresponds to a setting. Extra properties:
val - get or set the setting value corresponding to this value, e.g.
Root.page1.graph1.leftMargin.val = '2cm'
"""
class SettingGroupNode(Node):
"""A node corresponding to a setting group. No extra properties."""
class WidgetNode(Node):
"""A node corresponding to a widget.
property:
widgettype - get Veusz type of widget
Methods are below."""
def WalkWidgets(self, widgettype=None):
"""Generator to walk widget tree and get widgets below this
WidgetNode of type given.
widgettype is a Veusz widget type name or None to get all
widgets."""
def Add(self, widgettype, *args, **args_opt):
"""Add a widget of the type given, returning the Node instance.
"""
def Rename(self, newname):
"""Renames widget to name given.
Existing Nodes corresponding to children are no longer valid."""
def Action(self, action):
"""Applies action on widget."""
def Remove(self):
"""Removes a widget and its children.
Existing Nodes corresponding to children are no longer valid."""
Note that Nodes are temporary objects which are created on
the fly. A real widget in Veusz can have several different
WidgetNode objects. The operators == and != can test whether
a Node points to the same widget, setting or setting group.
Here is an example to set all functions in the document to
be ``x**2``:
.. code-block:: python
for n in Root.WalkWidgets(widgettype='function'):
n.function.val = 'x**2'
Translating old to new style
----------------------------
Here is an example how you might translate the old to new
style interface (this is taken from the ``sin.vsz``
example).
.. code-block:: python
# old (from saved document file)
Add('page', name='page1')
To('page1')
Add('graph', name='graph1', autoadd=False)
To('graph1')
Add('axis', name='x')
To('x')
Set('label', '\\italic{x}')
To('..')
Add('axis', name='y')
To('y')
Set('label', 'sin \\italic{x}')
Set('direction', 'vertical')
To('..')
Add('xy', name='xy1')
To('xy1')
Set('MarkerFill/color', 'cyan')
To('..')
Add('function', name='function1')
To('function1')
Set('function', 'sin(x)')
Set('Line/color', 'red')
To('..')
To('..')
To('..')
.. code-block:: python
# new (in python)
import veusz.embed
embed = veusz.embed.Embedded('window title')
page = embed.Root.Add('page')
# note: autoAdd=False stops graph automatically adding own axes (used in saved files)
graph = page.Add('graph', autoadd=False)
x = graph.Add('axis', name='x')
x.label.val = '\\italic{x}'
y = graph.Add('axis', name='y')
y.label.val = 'sin \\italic{x}'
y.direction.val = 'vertical'
xy = graph.Add('xy')
xy.MarkerFill.color.val = 'cyan'
func = graph.Add('function')
func.function.val = 'sin(x)'
func.Line.color.val = 'red'
PyQt programs
=============
There is no direct PyQt interface. The standard embedding interface
should work, however.
Non Python programs
===================
Support for non Python programs is available in a limited
form. External programs may execute Veusz using :command:`veusz
--listen`. Veusz will read its input from the standard input, and
write output to standard output. This is a full Python execution
environment, and supports all the scripting commands mentioned in
:ref:`Commands <Commands>`, a :command:`Quit()` command, the
:command:`EnableToolbar()` and the :command:`Zoom(factor)` command
listed above. Only one window is supported at once, but many
:command:`veusz --listen` programs may be started.
:command:`veusz --listen` may be used from the shell command line by
doing something like:
.. code-block:: bash
veusz --listen < in.vsz
where :command:`in.vsz` contains:
.. code-block:: python
To(Add('page') )
To(Add('graph') )
SetData('x', arange(20))
SetData('y', arange(20)**2)
Add('xy')
Zoom(0.5)
Export("foo.pdf")
Quit()
A program may interface with Veusz in this way by using the
:command:`popen` C Unix function, which allows a program to be started
having control of its standard input and output. Veusz can then be
controlled by writing commands to an input pipe.
|