/usr/share/doc/gri/html/X-Y.html is in gri-html-doc 2.12.26-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Gri: xy plots</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000EE" vlink="#551A8B" alink="FF0000">
<!-- newfile X-Y.html "Gri: xy plots" "X-Y Plots" -->
<!-- @node X-y Plots, Linegraphs, Pen Color, Top -->
<a name="X-yPlots" ></a>
<img src="./resources/top_banner.gif" alt="navigation map" usemap="#navigate_top" border="0">
<table summary="top banner" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="150" valign="top">
<font size=-1>
<br>
Chapters:
<br>
<a href="Introduction.html">1: Introduction</a><br>
<a href="SimpleExample.html">2: Simple example</a><br>
<a href="InvokingGri.html">3: Invocation</a><br>
<a href="GettingMoreControl.html">4: Finer Control</a><br>
<a href="X-Y.html">5: X-Y Plots</a><br>
<a href="ContourPlots.html">6: Contour Plots</a><br>
<a href="Images.html">7: Image Plots</a><br>
<a href="Examples.html">8: Examples</a><br>
<a href="Commands.html">9: Gri Commands</a><br>
<a href="Programming.html">10: Programming</a><br>
<a href="Environment.html">11: Environment</a><br>
<a href="Emacs.html">12: Emacs Mode</a><br>
<a href="History.html">13: History</a><br>
<a href="Installation.html">14: Installation</a><br>
<a href="Bugs.html">15: Gri Bugs</a><br>
<a href="TestSuite.html">16: Test Suite</a><br>
<a href="GriInThePress.html">17: Gri in Press</a><br>
<a href="Acknowledgments.html">18: Acknowledgments</a><br>
<a href="License.html">19: License</a><br>
<br>
Indices:<br>
<a href="ConceptIndex.html"><i>Concepts</i></a><br>
<a href="CommandIndex.html"><i>Commands</i></a><br>
<a href="BuiltinIndex.html"><i>Variables</i></a><br>
</font>
<td width="500" valign="top">
<map name="navigate_top">
<area alt="index.html#Top" shape="rect" coords="5,2,218,24" href="index.html#Top">
<area alt="index.html#Top" shape="rect" coords="516,2,532,24" href="index.html#Top">
<area alt="Gri: pen color" shape="rect" coords="557,2,573,24" href="PenColor.html">
<area alt="Gri: contour plots" shape="rect" coords="581,2,599,24" href="ContourPlots.html">
</map>
<map name="navigate_bottom">
<area alt="index.html#Top" shape="rect" coords="5,2,218,24" href="index.html#Top">
<area alt="Gri: contour plots" shape="rect" coords="581,2,599,24" href="ContourPlots.html">
</map>
<h1>5: X-Y Plots</h1>
<UL>
<LI><a href="X-Y.html#Linegraphs">Linegraphs</a>: x-y graphs with data connected by line segments
<LI><a href="X-Y.html#Scattergraphs">Scattergraphs</a>: x-y graphs with data indicated by symbols
<LI><a href="X-Y.html#FormulaPlots">Formula Plots</a>:
</UL>
<!-- @node Linegraphs, Scattergraphs, X-y Plots, X-y Plots -->
<a name="Linegraphs" ></a>
<h2>5.1: Linegraphs</h2>
The following Gri commands will draw a linegraph. For the output graph
(see <a href="GettingMoreControl.html#GettingMoreControl">Getting More Control</a>).
<p>
This plots a simple linegraph:
<p>
<A HREF="example1.png">
<IMG ALT="Example 1" SRC="example1-tiny.png"
ALIGN=top>
</A>
<TABLE SUMMARY="Example" BORDER="0" BGCOLOR="#efefef" WIDTH="100%">
<TR>
<TD>
<PRE>
<font color="#82140F">
# Example 1 -- Linegraph using data in a separate file
<p>
open example1.dat # Open the data file
read columns x y # Read (x,y) columns
draw curve # Draw data curve
draw title "Example 1" # Title above plot
</font></PRE>
</TD>
</TR>
</TABLE>
<p>
Here's what the command lines mean:
<p>
<ul>
<li>
The first line is a comment. Anything to the right of a hash-mark
`<font color="#82140F"><code>#</code></font>' is considered to be a comment. (This symbol is also called a
"pound".)
<p>
<li>
The second line is blank. Gri ignores blank lines between commands.
<li>
`<font color="#82140F"><code>open example1.dat</code></font>' tells Gri to open the indicated file (in
the current directory) as an input data file. You can specify files
outside the current directory by using conventional unix-shell pathnames
(e.g., `<font color="#82140F"><code>open ~/data/TS/section1/T_S.dat</code></font>' or
`<font color="82140F"><code>open ../data/file.dat</code></font>'). You can even use "synonyms" (see <a href="Synonyms.html#Synonyms">Synonyms</a>.) in
filenames, as in `<font color="#82140F"><code>open \BASENAME.dat</code></font>'.
<li>
`<font color="#82140F"><code>read columns x y</code></font>' tells Gri to start reading columnar data,
the first column being `<font color="#82140F"><code>x</code></font>', the second `<font color="#82140F"><code>y</code></font>'. `<font color="#82140F"><code>x</code></font>' and
`<font color="#82140F"><code>y</code></font>' are predefined names for whatever ends up on the horizontal and
vertical axes.
<p>
The number of data needn't be specified. Gri reads columns until a
blank line or end-of-file is found. You can tell Gri how many lines to
read with a command like `<font color="#82140F"><code>read columns 10 x y</code></font>'. Multiple datasets
can reside within one file; provided that they are separated by a single
blank line, Gri can access them by multiple `<font color="#82140F"><code>read</code></font>' commands.
<p>
Like C, Gri expects numbers to be separated by one or more spaces or
tabs. Commas are not allowed. If the columns were reversed, the
command would be `<font color="#82140F"><code>read columns y x</code></font>'. If there were an initial
column of extraneous data, the command would be
`<font color="#82140F"><code>read columns * x y</code></font>', or `<font color="#82140F"><code>read columns x=2 y=3</code></font>'
(see <a href="Read.html#ReadColumns">Read Columns</a>).
<li>
`<font color="#82140F"><code>draw curve</code></font>' tells Gri to draw a curve connecting the points
in the `<font color="#82140F"><code>x</code></font>' and `<font color="#82140F"><code>y</code></font>' columns. A nice scale will be selected
automatically. (You can change this or any other plot characteristics
easily, as you'll see later.)
<li>
`<font color="#82140F"><code>draw title</code></font>' tells Gri to write the indicated string
centered above the plot. The title <b>must</b> be enclosed in quotes.
<li>
`<font color="#82140F"><code>quit</code></font>' tells Gri to exit.
</ul>
<p>
Gri will draw axes automatically, and pick its own scales.
<p>
If you wish to draw several curves which cross each other, you should
try using `<font color="#82140F"><code>draw curve overlying</code></font>' instead of
`<font color="#82140F"><code>draw curve</code></font>'. This will make it easier to distinguish the
different curves.
<p>
<!-- @node Scattergraphs, Formula Plots, Linegraphs, X-y Plots -->
<a name="Scattergraphs" ></a>
<h2>5.2: Scattergraphs</h2>
This section contains two examples, the first being a fuller explanation
of all the bells and whistles, the second being a simple explanation
of how to get a very quick plot, given just a file containing a matrix
of grid data.
<p>
To get a scattergraph with symbols at the data points, substitute
`<font color="#82140F"><code>draw symbol</code></font>' for `<font color="#82140F"><code>draw curve</code></font>'. Both symbols and a curve
result if both `<font color="#82140F"><code>draw curve</code></font>' and `<font color="#82140F"><code>draw symbols</code></font>' are used.
See see <a href="GettingMoreControl.html#GettingMoreControl">Getting More Control</a> for an example.
<p>
By default, the symbol used is an x. To get another symbol, use a
command like `<font color="#82140F"><code>draw symbol 0</code></font>' or `<font color="#82140F"><code>draw symbol plus</code></font>'.
<p>
To change the symbol size from the default of 0.2 cm use commands like
`<font color="82140F"><code>set symbol size 0.1</code></font>' to set to 1 mm (see <a href="Set.html#SetSymbolSize">Set Symbol Size</a>).
<p>
<h3>5.2.1: Coding data with symbols</h3>
To get different symbols for different data points, insert symbol codes
from the above list as a column along with the x-y data, and substitute
the command `<font color="#82140F"><code>read columns x y z</code></font>', and then draw them with
`<font color="#82140F"><code>draw symbol</code></font>'. Gri will interpret the rounded-integer
values of the `<font color="#82140F"><code>z</code></font>' columns as symbol codes. Note that even if
you've read in a z column which you intend to represent symbols, it will
be overridden if you designate a specific symbol in your
`<font color="#82140F"><code>draw symbols</code></font>' command; thus `<font color="#82140F"><code>draw symbol 0</code></font>' puts a `<font color="#82140F"><code>+</code></font>'
at the data points whether or not you've read in a symbol column.
<p>
<h3>5.2.2: Drawing a symbol legend</h3>
The following example shows how you might write a symbol legend for a
plot. The legend is drawn 1 cm to the right of the right-hand side of
the axes, with the bottom of the legend one quarter of the way up the
plot; see <a href="Draw.html#DrawSymbolLegend">Draw Symbol Legend</a>. The lines in the legend are
double-spaced vertically. To change the location of the legend, alter
the `<font color="#82140F"><code>.legend_x. =</code></font>' and `<font color="#82140F"><code>.legend_y. =</code></font>' lines. To change the
spacing, alter the `<font color="#82140F"><code>.legend_y. +=</code></font>' line.
<p>
<TABLE SUMMARY="Example" BORDER="0" BGCOLOR="#efefef" WIDTH="100%">
<TR>
<TD>
<PRE>
<font color="#82140F">
set x axis -1 5 1
set y axis -1 5 1
read columns x y z
0 0 0
1 1 1
2 2 2
3 3 3
<p>
draw symbol
<p>
# Legend
.leg_x. = {rpn ..xmargin.. ..xsize.. + 1 +}
.leg_y. = {rpn ..ymargin.. ..ysize.. 4 / +}
draw symbol legend 0 "Foo" at .leg_x. .leg_y. cm
.leg_y. += {rpn "M" ascent 2 *}
draw symbol legend 1 "Bar" at .leg_x. .leg_y. cm
.leg_y. += {rpn "M" ascent 2 *}
</font></PRE>
</TD>
</TR>
</TABLE>
<p>
<h3>5.2.3: Coding data with symbol colors</h3>
To get different colors for different symbols, read a color code into
the z column, and do for example `<font color="#82140F"><code>draw symbol bullet color hue z</code></font>'.
The numerical color code ranges from 0 (red) through to 1, passing
through green at 1/3 and blue at 2/3.
<p>
<!-- @node Formula Plots, Contour Plots, Scattergraphs, X-y Plots -->
<a name="FormulaPlots" ></a>
<h2>5.3: Formula Plots</h2>
There are two methods for formula graphs.
<p>
<ol>
<p>
<li> <b>Use the system yourself.</b>
Do as in this example:
<p>
<TABLE SUMMARY="Example" BORDER="0" BGCOLOR="#efefef" WIDTH="100%">
<TR>
<TD>
<PRE>
<font color="#82140F">
open "awk 'BEGIN{for(i=0;i<3.141;i+=0.05)\
{print(i,cos(i))}}' |"
read columns x y
close
draw curve
</font></PRE>
</TD>
</TR>
</TABLE>
<p>
<li> <b>Let Gri calculate things for you</b>
<p>
The simplest is to let Gri
calculate things for you with the `<font color="#82140F"><code>create columns from function</code></font>'
command (see <a href="Create.html#Create">Create</a>). The command assumes that you have defined
the synonym called `<font color="#82140F"><code>\function</code></font>' which defines `<font color="#82140F"><code>y</code></font>' in terms of
`<font color="#82140F"><code>x</code></font>'.
<p>
Gri uses the program `<font color="#82140F"><code>awk</code></font>' to create the columns, and cannot work
without it.
<p>
Here is an example of using `<font color="#82140F"><code>create columns from function</code></font>':
<p>
<TABLE SUMMARY="Example" BORDER="0" BGCOLOR="#efefef" WIDTH="100%">
<TR>
<TD>
<PRE>
<font color="#82140F">
show "First 2 terms of perturbation expansion"
set y axis name horizontal
set y name "sea-level"
set x name "$\omega$t"
<p>
\b = "0.4" # perturbation parameter b=dH/H
\xmin = "0"
\xmax = "6.28"
\xinc = "3.14 / 20"
\function = "cos(x)"
set x axis \xmin \xmax
create columns from function
draw curve
draw title "SOLID LINE \function"
<p>
\function = "(cos(x)+\b/2*(1-cos(2*x)))"
create columns from function
set dash 1
draw curve
draw title "DASHED LINE \function"
<p>
draw title "b = \b"
</font></PRE>
</TD>
</TR>
</TABLE>
<p>
Here's another example, in which the curve `<font color="#82140F"><code>y = 1/(\int + \sl*x)</code></font>'
is drawn through some data. Note how `<font color="#82140F"><code>sprintf</code></font>' is used to set
`<font color="#82140F"><code>\xmin</code></font>' and `<font color="#82140F"><code>\xmax</code></font>' using the scales that Gri has determined
in reading the data.
<p>
<TABLE SUMMARY="Example" BORDER="0" BGCOLOR="#efefef" WIDTH="100%">
<TR>
<TD>
<PRE>
<font color="#82140F">
open file.data
read columns x y
close
draw symbol bullet
\int = "-0.1235"
\sl = "0.003685"
sprintf \xmin "%f" ..xleft..
sprintf \xmax "%f" ..xright..
\function = "1/(\int + x * \sl)"
create columns from function
draw curve
</font></PRE>
</TD>
</TR>
</TABLE>
<p>
</ol>
<p>
</table>
<img src="./resources/bottom_banner.gif" alt="navigation map" usemap="#navigate_bottom" border="0">
</body>
</html>
|