10.14 The piechart command
piechart ('<filename>'|<function>) [using <using specifier>] [select <select specifier>] [index <index specifier>] [every <every specifier>] [label <auto|key|inside|outside> <label>] [format <format string>] [with <style> [<style modifier> ... ] ]
Immediately after the piechart keyword, the file (or indeed, function) from which the data is to be taken should be specified; any of the modifiers taken by the plot command – i.e. using, index, etc. – may be used to specify which data from this data file should be used. The label modifier should be used to specify how a name for each pie wedge should be drawn from the data file, and has a similar syntax to the equivalent modifier in the plot command, except that the name string may be prefixed by a keyword to specify how the pie wedge names should be positioned. Four options are available:
Having specified a name for each wedge using the label modifier, the format modifier determines the final text which is printed along side each wedge. For example, a wedge with name ‘Europe’ might be labelled as ‘27% Europe’, applying the default format string:
Three variables may be used in format strings: label contains the name of the wedge as specified by the label modifier, percentage contains the numerical percentage size of the wedge, and wedgesize contains the absolute unnormalised size of the wedge, as read from the input data file, before the sizes were renormalised to sum to 100%.
The with modifier may be followed by the keywords color, linewidth, style, which all apply to the lines drawn around the circumference of the piechart and between its wedges. The fill color of the wedges themselves are taken sequentially from the current palette, as set by the set palette command. Note that Pyxplot’s default palette is optimised more for producing plots with datasets in different and distinct colors than for producing piecharts in aesthetically pleasing shades, where a little more subtly may be desirable. A suitable call to the set palette command is highly recommended before the piechart command is used.
As with the plot command, the position and size of the piechart are governed by the set origin and set size commands. The former determines where the centre of the piechart is positioned; the latter determines its diameter.