From J Wiki
Jump to: navigation, search
Plot | Verbs | Class Commands Data Options Outputs Types | Colors Fonts Keys Text YAxes | Function Multi Shape

Public verbs are pd and plot.

  • pd is the low-level verb that handles all calls to Plot.
  • plot is a cover verb for pd that will handle most simple uses of Plot.


pd is the low-level verb that handles all calls to Plot. It has three types of argument:

commands set up and show a plot
options specify plot type, colors etc
data data used in the plot

Commands and options are given in a character list, delimited by semicolons. Data is a numeric or boxed array.

For example:

load 'plot numeric trig'        NB. load plot and some utilities
pd 'reset'                      NB. command reset
pd 'textc 500 950 My Plot'      NB. command textc
pd 'type line'                  NB. option type
pd cos steps 0 8 100            NB. data
pd 'show'                       NB. command show
pd 'clip'                       NB. command clip
pd 'print'                      NB. command print

Plot options should be given before the data to which they apply. Options can be redefined for new data, e.g.

pd 'reset'
pd 'color red'
pd 1 2 3                        NB. data drawn in red
pd 'color blue'
pd 2 3 5                        NB. data drawn in blue
pd 'show'


plot is a cover for pd. For example, the following loads the plot system and draws a simple plot.

load 'plot'
plot */~ i:20

The optional left argument is a list of pd commands and options, delimited by semicolons. The right argument is data.

The first command may be a plot type, e.g. the following are equivalent:

'bar' plot data
'type bar' plot data

plot and pd may be used together, for example:

'bar;itemcolor red,green' plot >:?2 6$10      NB. draw a barchart
pd 'print'                                    NB. print it