TABULA/samples/plot test using Function plotline

From J Wiki
Jump to navigation Jump to search

This is SAMPLE (built-in). To work with this sample, enter $

plot test using Function plotline
┌   ┌ ┌ {1}        6 rad  angle
├ ┌ │ └>{2}   -0.279 /    sine
├ ├ └>  {3}    0.960 /    cosine
├ └>    {4}    0.681 /    sin+cos
└>      {5}       NO /    plot {2}{3}{4} vs {1}

Rationale

This sample shows how to plot a line chart using TABULA.

It is based on a simple t-table, to calculate: (sin a), (cos a) and (sin a + cos a) from a given angle: a (in radians).

There is a more general method, using stept and replot. Extended functionality is provided by menu: File > Plot 0 to (value) and related menu items.

The method described on this page requires a special item (line {5} here), but it offers the end-user a simpler way of displaying a (pre-determined) chart without needing to specify its bounds or format.

Try it out

  1. Select line {1} then enter 7
    Lines {2} {3} and {4} will change to new values.
  2. Select line {5} then enter 1
    A line chart will appear, plotting {2} {3} and {4} against item {1} over the range 0 to 7.
  3. Select line {1} then enter 8
    Not only will lines {2} {3} and {4} will change to new values, but the line chart will redraw itself to span the range 0 to 8
  4. Select line {5} then enter 0
    The line chart will be frozen, and will no longer redraw itself.
  5. Click the go-away button in the titlebar of the "plot" window to make it disappear.

Build this t-table

At this point you should see:

plot test using Function plotline
  {1}       6 rad  unit
┌ {2}       1 rad  a:feeder
└>{3} @ 0.841 /    sine
  • Merge {1} into the feeder line {2} to yield:
plot test using Function plotline
┌ {1}        6 rad  unit
└>{2} @ -0.279 /    sine
plot test using Function plotline
┌ ┌ {1}        6 rad  unit
│ └>{2}   -0.279 /    sine
└>  {3} @  0.960 /    cosine

At this point you should see:

plot test using Function plotline
  ┌ ┌ {1}        6 rad  unit
┌ │ └>{2}   -0.279 /    sine
├ └>  {3}    0.960 /    cosine
└>    {4}    0.681 /    sin+cos
    ┌ {5}        1 *    X:feeder
    ├ {6}        1 *    U:feeder
    ├ {7}        1 *    V:feeder
    ├ {8}        1 *    W:feeder
    └>{9}        0 *    plot {6} {7} {8} against {5}
  • As before, merge {1} into the feeder line {5}.
  • Likewise merge in-turn {2} {3} {4} into the feeder lines named U:feeder, V:feeder, W:feeder.