Plot/Text

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

Text can be written directly to the plot.

Text commands are processed after all other commands, so that the text overwrites the display.

Use textcolor to specify the color, and textfont to specify the font, for example:

pd 'textcolor RED'
pd 'textfont Arial 20 Bold'

See also plot Fonts.

To specify the text and position, use commands text, textc and textr for left justified, centered, and right justified text. The parameter is: position text

The position is the x and y position, relative to the current drawing box.

Text is drawn with the given position at the top. Thus for left-justified text, the position is the top left corner of the output.

  • an ordinary number is on a scale from 0 to 1000, with 0 0 at the bottom left.
  • a number with an x suffix such as 50x is in pixels (or drawing units)
  • a negative number (either as -50 or _50

Examples

pd 'text 100 200 market value'

writes text left justified at position 100 200 inside the current drawing box, considered to be of size 1000 1000.

pd 'text 50x 100x market value'

writes text left justified at position 50 100 pixels inside the current drawing box.

pd 'textr -51x 100x market value'

writes text right justified at position 50 100 pixels inside the current drawing box. The x position is measured from the right of the drawing box, offset by 1.