~ubuntu-branches/ubuntu/precise/gle-graphics/precise

« back to all changes in this revision

Viewing changes to gle-refman/graph/graph.tex

  • Committer: Bazaar Package Importer
  • Author(s): Christian T. Steigies
  • Date: 2010-02-24 23:21:37 UTC
  • mfrom: (2.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100224232137-f0qfufkxcr2tr1m5
Tags: 4.2.2-2
* upload to unstable
* Updated Standards-Version to 3.8.4 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
194
194
 
195
195
{\bf Auto key:}\index{key!data based} If the first row of a data file does not contain actual data but instead contains column labels, then these labels are used by GLE to create a key for the graph (Chapter~\ref{key:chap}). GLE automatically detects this case by checking if all fields in the first row are valid numbers or not. If not, then GLE assumes that the first row contains column labels. Column labels that include a space or that could be incorrectly interpreted as a number should be double quoted. Fig.~\ref{fig:autokey} illustrates this with an example.
196
196
 
197
 
\begin{figure}
 
197
\begin{figure}[tb]
198
198
\begin{minipage}[t]{6.35cm}%
199
199
\begin{Verbatim}
200
200
begin graph
317
317
\item {\sf bar}: similar to `{\sf hist}', but now also separates the bins with vertical lines.
318
318
\end{itemize}
319
319
 
320
 
\begin{figure}
 
320
\begin{figure}[tb]
321
321
\centering
322
322
\input{graph/fig/linemode.inc}
323
323
\caption{\label{linemode:fig}The {\sf impulses}, {\sf steps}, {\sf fsteps}, and {\sf hist} options of the line command.}
517
517
let d1 = sin(x), cos(x) from 0 to 2*pi
518
518
\end{Verbatim}
519
519
 
520
 
\item[{\sf let {\it dn} = [routine] {\it dm} [options]}]
 
520
\item[{\sf let {\it dn} = [routine] {\it dm} [options] [{\it slopevar}] [{\it offsetvar}] [{\it rsqvar}]}]
521
521
 
522
 
GLE includes several fitting routines that allow an equation to be fit to a data series. These routines can be included in a `let' expression as shown above, where {\it dn} will contain results of fitting {\sf routine} to the data in {\it dm}, and the {\sf [options]} control the limits to which the data in {\it dn} extends.
 
522
GLE includes several fitting routines that allow an equation to be fit to a data series. These routines can be included in a `let' expression as shown above, where {\it dn} will contain results of fitting {\sf routine} to the data in {\it dm}.
523
523
 
524
524
The following routines are available :
525
525
\begin{itemize}
529
529
\item \texttt{powxfit}\index{powxfit}: fits the data in \textit{dm} to the equation $y = a \cdot x^b$.
530
530
\end{itemize}
531
531
 
 
532
The value for $a$ is stored in `{\it slopevar}' and the value for $b$ is stored in `{\it offsetvar}'. The $r^2$ value of the fit is stored in `{\it rsqvar}'. Note that these variables are optional.
 
533
 
532
534
The following options are available :
533
535
\begin{itemize}
 
536
\item \texttt{from {\it xmin} to {\it xmax}} The range of the data in \textit{dn} extends from the \textit{xmin} to \textit{xmax} as specified by the user.
 
537
 
 
538
\item \texttt{step {\it xstep}} Specifies the x-resolution of the fitted equation. Similar to the \texttt{step} option of the \texttt{let} command.
 
539
 
 
540
\item \texttt{rsq {\it var}} The $r^2$ value of the fit will be stored in {\it var}.
 
541
 
 
542
\item \texttt{xmin {\it x1}}, \texttt{xmax {\it x2}}, \texttt{ymin {\it y1}}, \texttt{ymax {\it y2}} Only use data points from dm in the given window to fit the equation. That is, only data points $(x,y)$ from dm are used for which $x_1 \le x \le x_2$ and $y_1 \le y \le y_2$.
 
543
 
534
544
\item \texttt{limit\_data\_x} The range of the data in \textit{dn} extends from the minimum $x$ value in \textit{dm} to the maximum $x$ value in \textit{dm}.
535
545
 
536
546
\item \texttt{limit\_data\_y} The range of the data in \texttt{dn} extends from the $x$ value of the minimum $y$ value in \textit{dm} to the $x$ value of the maximum $y$ value in \textit{dm}.
537
547
 
538
548
\item \texttt{limit\_data} The range of the data in \textit{dn} extends from the greater of the $x$ value of the minimum $y$ value or the minimum $x$ value in \textit{dm} to the greater of the $x$ value of the maximum $y$ value or the maximum $x$ value in \textit{dm}.
539
 
 
540
 
\item \texttt{from {\it xmin} to {\it xmax}} The range of the data in \textit{dn} extends from the \textit{xmin} to \textit{xmax} as specified by the user.
541
549
\end{itemize}
542
550
 
543
 
\begin{minipage}[c]{8cm}
 
551
\begin{figure}[tb]
 
552
\begin{minipage}[c]{9.2cm}
544
553
\begin{Verbatim}
545
 
slope = 0; offs = 0
 
554
slope = 0; offs = 0; rsquare = 0
546
555
 
 
556
set texlabels 1
547
557
begin graph
548
 
   title  "Linear fit"
 
558
   title "Linear fit"
549
559
   xtitle "$x$"
550
560
   ytitle "$y = ax + b$"
551
 
   data   "fitlin.dat"
552
 
   let d2 = linfit d1 from 0 to 10 slope offs
553
 
   d1 marker circle
554
 
   d2 line
 
561
   data "data.csv"
 
562
   let d2 = linfit d1 from 0 to 10 slope offset rsquare
 
563
   d1 marker circle color blue
 
564
   d2 line color red
555
565
end graph
556
566
 
557
 
set just rc
558
 
amove xg(xgmax)-0.25 yg(2)
559
 
tex "$y = " + format$(slope,"fix 2") +
560
 
    "x + "  + format$(offs,"fix 2")  + "$"
 
567
begin key
 
568
   pos br nobox
 
569
   text "$y = "+format$(slope,"fix 2")+"x + "+format$(offset,"fix 2")+"$"
 
570
   text "$r^2 = "+format$(rsquare,"fix 2")+"$"
 
571
end key
561
572
\end{Verbatim}
562
573
\end{minipage}
563
574
\hfill
564
575
\begin{minipage}[c]{7cm}
565
576
\mbox{\input{graph/fig/gc_fit.inc}}
566
577
\end{minipage}
 
578
\caption{\label{fig:fitlin}Fitting linear equations `let d2 = fitlin d1'.}
 
579
\end{figure}
 
580
 
 
581
\begin{figure}[tb]
 
582
\begin{minipage}[c]{8cm}
 
583
\begin{Verbatim}
 
584
a = 0; b = 0; c = 0; d = 0; r = 0
 
585
 
 
586
set texlabels 1
 
587
begin graph
 
588
   xtitle "$x$"
 
589
   ytitle "$f(x)$"
 
590
   title "$f(x) = a\sin(bx)+cx^2+d$"
 
591
   data "data.csv"
 
592
   let d2 = fit d1 with a*sin(b*x)+c*x^2+d rsq r
 
593
   d1 marker circle color blue
 
594
   d2 line color red
 
595
end graph
 
596
 
 
597
fct$ = "$f(x) = "+format$(a,"fix 2")+ &
 
598
       "\sin("+format$(b,"fix 2")+"x)+"+ &
 
599
       format$(c,"fix 2")+"x^2+"+ &
 
600
       format$(d,"fix 2")+"$"
 
601
 
 
602
begin key
 
603
   pos br nobox
 
604
   text fct$
 
605
   text "$r^2$ = "+format$(r,"fix 3")
 
606
end key
 
607
\end{Verbatim}
 
608
\end{minipage}
 
609
\hfill
 
610
\begin{minipage}[c]{7cm}
 
611
\mbox{\input{graph/fig/gc_fitfct.inc}}
 
612
\end{minipage}
 
613
\caption{\label{fig:fitfct}Fitting arbitrary curves `let d2 = fit d1 with $\ldots$'.}
 
614
\end{figure}
 
615
 
 
616
\item[{\sf let {\it dn} = fit {\it dm} with {\it eqn} [options]}]
 
617
 
 
618
Fit the coefficients of a given equation so that it best fits the data in dataset dm. Fig.~\ref{fig:fitfct} shows an example. The equation to fit is given by the `\texttt{with}' option. In this example, it is $a\sin(bx)+cx^2+d$. GLE will search for values for the coefficients $a$, $b$, $c$, and $d$ such that the given equation fits dm best. Note that all used coefficients must be initialized to zero before the graph block (see figure).
 
619
 
 
620
The fit command has the same options as the linfit command. In addition, it has the following settings.
 
621
 
 
622
\begin{itemize}
 
623
\item \texttt{with {\it eqn}} Gives the equation to fit.
 
624
 
 
625
\item \texttt{eqstr {\it strvar\$}} Sets the string variable in which the string representation of the fitted equation is to be stored.
 
626
 
 
627
\item \texttt{format {\it fmt\$}} Sets the numeric format to use while converting the fitted equation into its string representation. See the documentation of {\sf format\$} on page~\pageref{formatnum:pg} for a description of the syntax.
 
628
\end{itemize}
567
629
 
568
630
\item[{\sf let ds = hist dm [from {\it x1}] [to {\it x2}] [bins {\it n}] [step {\it n}]}]
569
631
\index{histogram}\index{let!hist}
851
913
 
852
914
If there isn't enough room on the line for all the names then simply use an extra {\sf xnames} command.
853
915
 
854
 
\begin{figure}
 
916
\begin{figure}[tb]
855
917
\begin{minipage}[c]{8cm}
856
918
\begin{Verbatim}
857
919
begin graph
1101
1163
\index{horiz}
1102
1164
The option `{\sf horiz}' makes the bars horizontal instead of vertical (Fig.~\ref{hbar:fig}).
1103
1165
 
1104
 
\begin{figure}
 
1166
\begin{figure}[tb]
1105
1167
\centering
1106
1168
\input{graph/fig/gc_horizbar.inc}
1107
1169
\caption{\label{hbar:fig}Illustration of the `{\sf horiz}' and `{\sf pattern}' keywords of the `{\sf bar}' command, and of the `{\sf angle}' option of the `{\sf yaxis}' command.}