[plotting] stub for errorbar plotting, more fixes
This commit is contained in:
parent
a8a0219c84
commit
1fa915b675
@ -261,12 +261,12 @@ additional options consult the help.
|
||||
|
||||
\subsection{Changing properties of a line plot}
|
||||
|
||||
Die properties of line plots can be changed by passing more arguments
|
||||
to the \varcode{plot} function. The command show in
|
||||
listing\,\ref{settinglineprops} creates line plot using the dotted
|
||||
line style, setting the line width to 1.5pt, a red line color is
|
||||
chosen, and star marker symbols will be used. Finally the name of the
|
||||
curve is set to 'plot 1' which will be displayed in a legend, if
|
||||
The properties of line plots can be changed by passing more arguments
|
||||
to the \varcode{plot} function. The command shown in
|
||||
listing\,\ref{settinglineprops} creates a line plot using the dotted
|
||||
line style, sets the line width to 1.5pt, a red line color is
|
||||
chosen, and star marker symbols is used. Finally, the name of the
|
||||
curve is set to \emph{plot 1} which will be displayed in a legend, if
|
||||
chosen.
|
||||
|
||||
\begin{lstlisting}[label=settinglineprops, caption={Setting line properties when calling \varcode{plot}.}]
|
||||
@ -277,7 +277,7 @@ chosen.
|
||||
\begin{important}[Choosing the right color.]
|
||||
Choosing the perfect color goes a little bit beyond personal
|
||||
taste. When creating a colored plot you may want to consider the
|
||||
following:
|
||||
following points:
|
||||
\begin{itemize}
|
||||
\item A substantial amount (about 9\%) of the male population can
|
||||
not distinguish between red and green.
|
||||
@ -293,13 +293,13 @@ The first thing a data plot needs are axis labels with a correct
|
||||
unit. By calling the functions \code[xlabel]{xlabel('Time [ms]')} and
|
||||
\code[ylabel]{ylabel{'Voltage [mV]'}} these can be set. By default the
|
||||
axes will be scaled to show the whole data range. The extremes will be
|
||||
selected as the closest integer for small values of the next full
|
||||
selected as the closest integer for small values or the next full
|
||||
multiple of tens, hundreds, thousands, etc.\ depending on the maximum
|
||||
value. If these defaults do not match our needs the limits of the axes
|
||||
can be explicitly set with the functions \code[xlim()]{xlim()} and
|
||||
\code[ylim()]{ylim()} functions. To do this, the functions expect a
|
||||
single argument that is a vector containing the minimum and maximum
|
||||
value. Table\,\ref{plotaxisprops} list some of the commonly adjusted
|
||||
value. If these defaults do not match our needs, the limits of the
|
||||
axes can be explicitly set with the functions \code[xlim()]{xlim()}
|
||||
and \code[ylim()]{ylim()}. To do this, the functions expect a single
|
||||
argument, that is a vector containing the minimum and maximum
|
||||
value. Table\,\ref{plotaxisprops} lists some of the commonly adjusted
|
||||
properties of an axis. These properties can be set using the
|
||||
\code[set()]{set()} function. The \code{set} function expects as a
|
||||
first argument a \enterm{handle} of the affected axis. An axis handle
|
||||
@ -307,8 +307,9 @@ of the current plot is returned by the \code[gca]{gca} function (gca
|
||||
stands for ``get current axis''). The following arguments passed to
|
||||
\code{set} are pairs of the property name and the desired value. It is
|
||||
possible to set any number of properties using a single call to
|
||||
\code{set}. See listing\,\ref{niceplotlisting} (lines 20 and 21) for an
|
||||
example.
|
||||
\code{set}. See listing\,\ref{niceplotlisting} (lines 20 and 21) for
|
||||
an example (these commands could be joined into a single call to
|
||||
\code{set} but have been split for better readability).
|
||||
|
||||
\begin{table}[tp]
|
||||
\titlecaption{Incomplete list of axis properties.}{For a complete
|
||||
@ -317,18 +318,18 @@ example.
|
||||
value of a property it will be listed first.}\label{plotaxisprops}
|
||||
\begin{tabular*}{1\textwidth}{lp{5.8cm}p{5.5cm}} \hline
|
||||
\textbf{property} & \textbf{Description} & \textbf{options} \erh
|
||||
\\ \hline \code{Box} & Defines whether the axes are drawn an all
|
||||
\\ \hline \code{Box} & Defines whether the axes are drawn on all
|
||||
sides. & $\{'on'|'off'\}$ \erb\\
|
||||
\code{Color} & Background color of the drawing area, not the whole figure. & Any RGB or CMYK
|
||||
values. \\
|
||||
\code{FontName} & Name of the font used for labeling. & Installed fonts. \\
|
||||
\code{FontSize} & Fontsize used for labels. & any scalar value.\\
|
||||
\code{FontSize} & Size of the font used for labels. & Any scalar value.\\
|
||||
\code{FontUnit} & Unit in which the font size is given. & $\{'points' | 'centimeters' | 'inches',
|
||||
...\}$\\ \code{FontWeight} & Bold or normal font. & $\{'normal' | 'bold'\}$\\
|
||||
\code{TickDir} & Direction of the axis ticks. & $\{'in' | 'out'\}$\\
|
||||
\code{TickLength} & Length of the ticks. & scalar value\\
|
||||
\code{TickLength} & Length of the ticks. & A scalar value\\
|
||||
\code{X-, Y-, ZDir} & Direction of axis scaling. Zero bottom/left, or not? & $\{'normal' | 'reversed'\}$\\
|
||||
\code{X-, Y-, ZGrid} & Defines whether grid line for the respective axes should be plotted? &
|
||||
\code{X-, Y-, ZGrid} & Defines whether grid lines for the respective axes should be plotted? &
|
||||
$\{'off'|'on'\}$ \\
|
||||
\code{X-, Y-, ZScale} & Linear of logarithmic scaling? & $\{'linear' | 'log'\}$\\
|
||||
\code{X-, Y-, ZTick} & Position of the tick marks. & Vector of positions.\\
|
||||
@ -337,10 +338,12 @@ example.
|
||||
\end{table}
|
||||
|
||||
|
||||
\subsection{Changing the figure properties}
|
||||
\subsection{Changing figure properties}
|
||||
|
||||
\begin{table}[tp]
|
||||
\titlecaption{Incomplete list of available figure properties.}{For a complete reference consult the \matlab{} help or select the property editor while having the figure background selected
|
||||
\titlecaption{Incomplete list of available figure properties.}{For a
|
||||
complete reference consult the \matlab{} help or select the
|
||||
property editor while having the figure background selected
|
||||
(\figref{ploteditorfig}).}\label{plotfigureprops}
|
||||
\begin{tabular*}{1\textwidth}{lp{6.6cm}p{5.7cm}} \hline
|
||||
\textbf{property} & \textbf{description} & \textbf{options}
|
||||
@ -354,15 +357,15 @@ example.
|
||||
\end{tabular*}
|
||||
\end{table}
|
||||
|
||||
Like axes also the whole figure has several properties that can be
|
||||
adjusted to the current needs. Most notably the paper (figure) size
|
||||
and the placement of the axes on the
|
||||
paper. Table\,\ref{plotfigureprops} lists commonly used ones. For a
|
||||
complete reference check the help. To change the properties, we again
|
||||
use the \code{set()} function. The first argument is now a handle to
|
||||
the current figure, not the current axis as before. Analogously to the
|
||||
\code{gca} command there is a \code{gcf} (``get current figure'')
|
||||
command with which the handle can be retrieved.
|
||||
Like axes, also figure has several properties that can be adjusted to
|
||||
the current needs. Most notably the paper (figure) size and the
|
||||
placement of the axes on the paper. Table\,\ref{plotfigureprops} lists
|
||||
commonly used properties. For a complete reference check the help. To
|
||||
change the properties, we again use the \code{set()} function. The
|
||||
first argument is now a handle to the current figure, not the current
|
||||
axis as before. Analogously to the \code{gca} command there is a
|
||||
\code{gcf} (``get current figure'') command with which the handle can
|
||||
be retrieved.
|
||||
|
||||
The script shown in the listing\,\ref{niceplotlisting} exemplifies
|
||||
several features of the plotting system and automatically generates
|
||||
@ -370,10 +373,11 @@ and saves figure\,\ref{spikedetectionfig}. With any execution of this
|
||||
script exactly the same plot will be created. If we decided to plot a
|
||||
different recording, the format will stay exactly the same, just the
|
||||
data changes. Of special interest are the lines 22 and 23 which set
|
||||
the size of the figure and line 26 which saves the figure in the 'pdf'
|
||||
format to file. When calling the function \code{saveas()} the first
|
||||
argument is the current figure handle a, the second the file name, and
|
||||
the last one defines the output format (box\,\ref{graphicsformatbox}).
|
||||
the size of the figure and positions the axes on the paper. Line 26
|
||||
finally saves the figure in the 'pdf' format to file. When calling the
|
||||
function \code{saveas()} the first argument is the current figure
|
||||
handle, the second the file name, and the last one defines the
|
||||
output format (box\,\ref{graphicsformatbox}).
|
||||
|
||||
\begin{figure}[t]
|
||||
\includegraphics{spike_detection} \titlecaption{Automatically
|
||||
@ -387,11 +391,11 @@ the last one defines the output format (box\,\ref{graphicsformatbox}).
|
||||
\item \enterm{Bitmaps}
|
||||
\item \enterm{Vector graphics}
|
||||
\end{enumerate}
|
||||
When using bitmaps a color is given for each pixel of the stored
|
||||
figure. Bitmaps do have a fixed resolution (e.g.\,300\,dpi --- dots
|
||||
per inch), they are very useful for photographs. In the contrary
|
||||
vector graphics store descriptions of the graphic in terms of so
|
||||
called primitives (lines, circles, polygons, etc.). The main
|
||||
When using bitmaps a color value is given for each pixel of the
|
||||
stored figure. Bitmaps do have a fixed resolution (e.g.\,300\,dpi
|
||||
--- dots per inch), they are very useful for photographs. In the
|
||||
contrary, vector graphics store descriptions of the graphic in terms
|
||||
of so called primitives (lines, circles, polygons, etc.). The main
|
||||
advantage of a vector graphic is that it can be scaled without a
|
||||
loss of quality.
|
||||
|
||||
@ -445,7 +449,7 @@ A very common scenario is to combine several plots in the same
|
||||
figure. To do this we create so-called subplots
|
||||
figures\,\ref{regularsubplotsfig},\,\ref{irregularsubplotsfig}. The
|
||||
\code[subplot()]{subplot()} command allows to place multiple axes onto
|
||||
a single paper. Generally, \varcode{subplot} expects three argument
|
||||
a single sheet of paper. Generally, \varcode{subplot} expects three argument
|
||||
defining the number of rows, column, and the currently active
|
||||
plot. The currently active plot number starts with 1 and goes up to
|
||||
$rows \cdot columns$ (numbers in the subplots in
|
||||
@ -465,10 +469,10 @@ figures\,\ref{regularsubplotsfig}, \ref{irregularsubplotsfig}).
|
||||
basicstyle=\ttfamily\scriptsize]{regular_subplot.m}
|
||||
|
||||
By default, all subplots have the same size, if something else is
|
||||
desired, e.g., one subplot should span a whole row, while two others
|
||||
are smaller and placed side by side in the same row, the third
|
||||
argument of \varcode{subplot} can be a vector or numbers that should
|
||||
be joined. These have, of course, be adjacent numbers
|
||||
desired, e.g.\ one subplot should span a whole row, while two others
|
||||
are smaller and should be placed side by side in the same row, the
|
||||
third argument of \varcode{subplot} can be a vector or numbers that
|
||||
should be joined. These have, of course, to be adjacent numbers
|
||||
(\figref{irregularsubplotsfig},
|
||||
listing\,\ref{irregularsubplotslisting}).
|
||||
|
||||
@ -493,6 +497,48 @@ used cells of the grid by passing a vector as the third argument to
|
||||
basicstyle=\ttfamily\scriptsize]{irregular_subplot.m}
|
||||
|
||||
|
||||
\subsection{Show estimation errors}
|
||||
The repeated measurements of a quantity almost always results in
|
||||
varying results. Neuronal activity, for example is notoriously
|
||||
noisy. The responses of a neuron to repeated stimulation with the same
|
||||
stimulus may share common features but are different each time. This
|
||||
is the reason we calculate measures that describe the variability of
|
||||
such as the standard deviation and thus need a way to
|
||||
illustrate it in plots of scientific data. Providing an estimate of
|
||||
the error gives the reader the chance of assessing the reliability of
|
||||
the data and get a feeling of possible significance of a
|
||||
difference in the average values.
|
||||
|
||||
\Matlab{} offers several ways to plot the average and the error. We
|
||||
will introduce two possible ways.
|
||||
\begin{itemize}
|
||||
\item The \code[errorbar()]{errorbar} function (figure\,\ref{errorbarplot}).
|
||||
\item Using the \code[{fill()]{fill} function to draw an area showing
|
||||
the spread of the data (figure\,\ref{errorareaplot}).
|
||||
\end{itemize}
|
||||
|
||||
\subsubsection{Errorbar}
|
||||
|
||||
Using the \code[errorbar()]{errorbar} function is rather straight
|
||||
forward. In its easiest form, it expects three arguments being the x- and y-values plus the
|
||||
error.
|
||||
|
||||
\begin{figure}[ht]
|
||||
\includegraphics[]{} \titlecaption{Adding error bars to a line
|
||||
plot}{\textbf{A} symmetrical error around the mean (e.g. using the
|
||||
standard deviation). \textbf{B} asymmetrical errors (e.g. the
|
||||
lower and upper quartiles). \textbf{C} X- and Y-error. See
|
||||
listing\,\ref{errorbarlisting}}\label{errrorbarplot}
|
||||
\end{figure}
|
||||
|
||||
|
||||
\begin{figure}[ht]
|
||||
\includegraphics[]{}
|
||||
\titlecaption{}\label{errrorareaplot}
|
||||
\end{figure}
|
||||
|
||||
|
||||
|
||||
\subsection{Annotations, text}
|
||||
|
||||
Sometimes want to highlight certain parts of a plot or simply add an
|
||||
@ -521,13 +567,13 @@ documentation.
|
||||
|
||||
\begin{important}[Positions in data or figure coordinates.]
|
||||
A very confusing pitfall are the different coordinate systems used
|
||||
by \varcode{text} and \varcode{annotation}. While text expects the
|
||||
positions to be in data coordinates, i.e.\,in the limits of the x-
|
||||
and y-axis, \varcode{annotation} requires the positions to be given
|
||||
in normalized figure coordinates. Normalized means that the width
|
||||
and height of the figure are expressed by numbers in the range 0 to
|
||||
1. The bottom/left corner then has the coordinates $(0,0)$ and the
|
||||
top/right corner the $(1,1)$.
|
||||
by \varcode{text} and \varcode{annotation}. While \varcode{text}
|
||||
expects the positions to be in data coordinates, i.e.\,in the limits
|
||||
of the x- and y-axis, \varcode{annotation} requires the positions to
|
||||
be given in normalized figure coordinates. Normalized means that the
|
||||
width and height of the figure are expressed by numbers in the range
|
||||
0 to 1. The bottom/left corner then has the coordinates $(0,0)$ and
|
||||
the top/right corner the $(1,1)$.
|
||||
|
||||
Why different coordinate systems? Using data coordinates is
|
||||
convenient for annotations within a plot, but what about an arrow
|
||||
|
Reference in New Issue
Block a user