07.05.2015 Views

Download the documentation - True BASIC

Download the documentation - True BASIC

Download the documentation - True BASIC

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Advanced Graph Control 109<br />

Implicit X-Coordinates<br />

Many datasets have straightforward x coordinates. The most common coordinates<br />

are 1, 2, 3, . . . . Graphing datasets with <strong>the</strong>se coordinates requires a very simple x()<br />

array: x(1) = 1, x(2) = 2, and so forth.<br />

You can skip <strong>the</strong> chore of setting up such simple x arrays when graphing datasets.<br />

Just pass an x array with no elements, created by a statement such as dim x(0).<br />

Then <strong>the</strong> x() array will be ignored when plotting data points.<br />

If <strong>the</strong> graph has a fixed x scale – you’ve called SetXscale or are overlaying an existing<br />

graph – <strong>the</strong> graphing routines will use that scale. They will evenly space data points<br />

along <strong>the</strong> graph’s x scale with <strong>the</strong> first point at <strong>the</strong> minimum x value and <strong>the</strong> last<br />

point at <strong>the</strong> maximum.<br />

If, on <strong>the</strong> o<strong>the</strong>r hand, <strong>the</strong> graph is auto-scaled, <strong>the</strong>n <strong>the</strong> graphing routines will base<br />

<strong>the</strong> data points’ x coordinates on <strong>the</strong> lower and upper bounds of <strong>the</strong> y array. When y’s<br />

lower bound is 1, this gives 1, 2, 3, ... as <strong>the</strong> x coordinates. But if you used dim y(-10<br />

to 10) <strong>the</strong> x coordinates will reflect <strong>the</strong>se bounds: -10, -9, ..., 9, 10.<br />

You can use null x arrays with any kind of scatter plot.<br />

Horizontal and Vertical Grid Lines<br />

It’s easy to get horizontal and/or vertical grid lines on your graph. Just add this<br />

statement somewhere before you actually draw a graph:<br />

call SetGrid(“hv”)<br />

The string “hv” gives both horizontal and vertical grid lines. You can also use “h” to<br />

get only horizontal grid lines or “v” to get only vertical grid lines.<br />

To get dashed, dotted, or dash-dotted grid lines, give <strong>the</strong> appropriate symbols after <strong>the</strong><br />

h or v. For instance, call SetGrid(“h.v-.”) to get dotted horizontal lines and dot-dashed<br />

vertical lines. See <strong>the</strong> description of SetGrid in <strong>the</strong> “Low-Level Control” section.<br />

The grid-line instructions stay in effect until your program stops; if you draw several<br />

graphs in a row, each will have <strong>the</strong> same kind of grid lines. You can turn off <strong>the</strong> grid<br />

lines entirely by calling SetGrid(““).<br />

The Graph’s Canvas Color<br />

You can give <strong>the</strong> canvas its own color to make it stand out from <strong>the</strong> rest of <strong>the</strong><br />

screen. The canvas color is like a background color for <strong>the</strong> canvas. (In fact, it’s not<br />

really a background color; it’s one of <strong>the</strong> foreground colors.) You can use any<br />

foreground color as <strong>the</strong> graph’s canvas color. Thus for a red canvas:<br />

call SetCanvas(“red”)<br />

01/01

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!