<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>boxes &#8211; Gnuplotting</title>
	<atom:link href="./index.html?simply_static_page=1695" rel="self" type="application/rss+xml" />
	<link>./../../../index.html</link>
	<description>Create scientific plots using gnuplot</description>
	<lastBuildDate>Mon, 02 Jan 2023 18:38:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>
	<item>
		<title>Calculating histograms</title>
		<link>./../../../calculating-histograms/index.html</link>
					<comments>./../../../calculating-histograms/index.html#comments</comments>
		
		<dc:creator><![CDATA[hagen]]></dc:creator>
		<pubDate>Wed, 16 Apr 2014 09:59:48 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[boxes]]></category>
		<category><![CDATA[histogram]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[macros]]></category>
		<guid isPermaLink="false">./../../../index.html?p=1924</guid>

					<description><![CDATA[Gnuplot comes with the possibility of plotting histograms, but this requires that the data in the individual bins was already calculated. Here, we start with an one dimensional set of data that we want to count and plot as an histogram, similar to the hist() function we find in Octave. Fig. 1 Two different distributions [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Gnuplot comes with the possibility of <a href="./../../../manpage-gnuplot-4-6/index.html#Q1-1-147">plotting histograms</a>, but this requires that the data in the individual bins was already calculated. Here, we start with an one dimensional set of data that we want to count and plot as an histogram, similar to the <code>hist()</code> function we find in Octave.</p>
<div class="figure">
    <img decoding="async" src="./../../../figs/histogram1.png" alt="Histogram of angle data"/></p>
<p class="caption">
        <strong>Fig. 1 </strong> Two different distributions of measured angles. (<a href="./../../../code/histogram1.gnu" type="text/plain" rel="nofollow">code to produce this figure</a>, <a href="./../../../code/hist.fct" rel="nofollow">hist.fct</a>, <a href="./../../../data/histogram.txt" rel="nofollow">data</a>)
    </p>
</div>
<p>In Fig. 1 you see two different distributions of measured angles. They were both given as one dimensional data and plotted with a defined macro that is doing the histogram calculation. The macro is defined in an additional file <code>hist.fct</code> and loaded before the plotting command.</p>
<pre class="prettyprint">
binwidth = 4
binstart = -100
load 'hist.fct'
plot 'histogram.txt' i 0 @hist ls 1,\
     ''              i 1 @hist ls 2
</pre>
<p>The content of <code>hist.fct</code>, including the definition of <code>@hist</code> looks like this</p>
<pre class="prettyprint">
# set width of single bins in histogram
set boxwidth 0.9*binwidth
# set fill style of bins
set style fill solid 0.5
# define macro for plotting the histogram
hist = 'u (binwidth*(floor(($1-binstart)/binwidth)+0.5)+binstart):(1.0) smooth freq w boxes'
</pre>
<p>For a detailed discussion on why <code>@hist</code> calculates a histogram you should have a look at <a href="http://stackoverflow.com/questions/2471884/histogram-using-gnuplot">this discussion</a> and the documentation about the <a href="./../../../manpage-gnuplot-4-6/index.html#Q1-1-300" class="manpage">smooth freq</a> which basically counts points with the same x-value. The other settings in the file define the width of a single bin plotted as a box and its fill style.</p>
<div class="figure">
    <img decoding="async" src="./../../../figs/histogram2.png" alt="Histogram of angle data"/></p>
<p class="caption">
        <strong>Fig. 2 </strong> Two different distributions of measured angles. The bins of the histograms are shifted to be centered around 0°. (<a href="./../../../code/histogram2.gnu" type="text/plain" rel="nofollow">code to produce this figure</a>, <a href="./../../../code/hist.fct" rel="nofollow">hist.fct</a>, <a href="./../../../data/histogram.txt" rel="nofollow">data</a>)
    </p>
</div>
<p>It is important that the two values <code>binwidth</code> and <code>binstart</code> are defined before loading the <code>hist.fct</code> file. These define the width of the single bins and at what position the left border of a single bin should be positioned. For example, let us assume that we want to have the bins centered around 0° as shown in Fig. 2. This can be achieved by settings the binstart to half the binwidth:</p>
<pre class="prettyprint">
binwidth = 4
binstart = -2
load 'hist.fct'
plot 'histogram.txt' i 0 @hist ls 1,\
     ''              i 1 @hist ls 2
</pre>
]]></content:encoded>
					
					<wfw:commentRss>./../../../calculating-histograms/feed/index.html</wfw:commentRss>
			<slash:comments>17</slash:comments>
		
		
			</item>
		<item>
		<title>Plotting more advanced statistical data</title>
		<link>./../../../plotting-more-advanced-statistical-data/index.html</link>
					<comments>./../../../plotting-more-advanced-statistical-data/index.html#comments</comments>
		
		<dc:creator><![CDATA[hagen]]></dc:creator>
		<pubDate>Thu, 23 Sep 2010 19:31:51 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ANOVA]]></category>
		<category><![CDATA[border]]></category>
		<category><![CDATA[boxes]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[errorbars]]></category>
		<category><![CDATA[index]]></category>
		<guid isPermaLink="false">./../../../index.html?p=561</guid>

					<description><![CDATA[In the last entry we had mean and standard variation data for five different conditions. Now let us assume that we have only two different conditions, but have measured with three different instruments A, B and C. We have used a ANOVA to verify that the data for the two conditions are significant different. As [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In the <a href="./../../../simple-statistic-plots/index.html">last entry</a> we had mean and standard variation data for five different conditions. Now let us assume that we have only two different conditions, but have measured with three different instruments A, B and C. We have used a ANOVA to verify that the data for the two conditions are significant different. As a result the plot in Fig. 1 should be created.</p>
<div class="figure">
    <img decoding="async" src="./../../../figs/statistics.png" alt="statistics" width="350"/></p>
<p class="caption">
        <strong>Fig. 1 </strong>Plot the mean and variance of the given <a href="./../../../data/statistics.dat">data</a> (<a href="./../../../code/statistics.gnu" type="text/plain">code to produce this figure</a>)
    </p>
</div>
<p>Therefore we store our data in a format, that can be used by the <code>index</code> command in Gnuplot. Note that the data have two empty lines between the blocks in the real <a href="./../../../data/statistics.dat">data file</a>:</p>
<pre>
# mean      std
# A
0.77671    0.20751
0.33354    0.30969
 
 
# B
0.64258    0.22984
0.19621    0.22597
 
 
# C
0.49500    0.31147
0.14567    0.21857
</pre>
<p>Now every instrument is stored in a different data block containing both conditions as columns.</p>
<p>The color definitions and axes settings are done in a similar way as in <a href="./../../../simple-statistic-plots/index.html">the previous blog entry</a>. Note that we have to define two more colors for the boxes, because we use three different colors. Also we define a black line to plot the significance indicator (arrow).</p>
<pre class="prettyprint">
<span class="k">set</span> style line <span class="n">1</span> lc rgb <span class="s">'gray30'</span> lt <span class="n">1</span> lw <span class="n">2</span>
<span class="k">set</span> style line <span class="n">2</span> lc rgb <span class="s">'gray40'</span> lt <span class="n">1</span> lw <span class="n">2</span>
<span class="k">set</span> style line <span class="n">3</span> lc rgb <span class="s">'gray70'</span> lt <span class="n">1</span> lw <span class="n">2</span>
<span class="k">set</span> style line <span class="n">4</span> lc rgb <span class="s">'gray90'</span> lt <span class="n">1</span> lw <span class="n">2</span>
<span class="k">set</span> style line <span class="n">5</span> lc rgb <span class="s">'black'</span> lt <span class="n">1</span> lw <span class="n">1.5</span>
<span class="k">set</span> style fill solid <span class="n">1.0</span> border rgb <span class="s">'grey30'</span>
</pre>
<p>The significance indicator is created by three black arrows and a text label:</p>
<pre class="prettyprint">
<span class="C"># Draw line for significance test</span>
<span class="k">set</span> arrow <span class="n">1</span> from <span class="n">0</span>,<span class="n">1</span> to <span class="n">1</span>,<span class="n">1</span> nohead ls <span class="n">5</span>
<span class="k">set</span> arrow <span class="n">2</span> from <span class="n">0</span>,<span class="n">1</span> to <span class="n">0</span>,<span class="n">0.95</span> nohead ls <span class="n">5</span>
<span class="k">set</span> arrow <span class="n">3</span> from <span class="n">1</span>,<span class="n">1</span> to <span class="n">1</span>,<span class="n">0.95</span> nohead ls <span class="n">5</span>
<span class="k">set</span> label <span class="s">'**'</span> at <span class="n">0.5</span>,<span class="n">1.05</span> center
</pre>
<p>For the plot the <code>index</code> command is used to plot first condition A, then B and then C by using block 0,1, and 2 respectively. The <code>x</code>-position of the boxes for instrument A are slightly shifted to the left, the ones for C to the right by subtracting or adding the value of <code>bs</code>. The value of <code>bs</code> has the width of one box in order to plot the boxes side by side.</p>
<pre class="prettyprint">
<span class="C"># Size of one box</span>
<span class="v">bs</span> <span class="o">=</span> <span class="n">0.2</span>
<span class="C"># Plot mean with variance (std^2) as boxes with yerrorbar</span>
<span class="k">plot</span> <span class="s">'statistics.dat'</span> i <span class="n">0</span> u (<span class="v">$0</span><span class="o">-</span><span class="v">bs</span>):<span class="n">1</span>:(<span class="v">$2</span><span class="o">**</span><span class="n">2</span>) notitle w yerrorb ls <span class="n">1</span>, \
     <span class="s">''</span>               i <span class="n">0</span> u (<span class="v">$0</span><span class="o">-</span><span class="v">bs</span>):<span class="n">1</span>:(<span class="v">bs</span>) t <span class="s">'A'</span> w boxes ls <span class="n">2</span>, \
     <span class="s">''</span>               i <span class="n">1</span> u <span class="n">0</span>:<span class="n">1</span>:(<span class="v">$2</span><span class="o">**</span><span class="n">2</span>) notitle w yerrorb ls <span class="n">1</span>, \
     <span class="s">''</span>               i <span class="n">1</span> u <span class="n">0</span>:<span class="n">1</span>:(<span class="v">bs</span>) t <span class="s">'B'</span> w boxes ls <span class="n">3</span>, \
     <span class="s">''</span>               i <span class="n">2</span> u (<span class="v">$0</span><span class="o">+</span><span class="v">bs</span>):<span class="n">1</span>:(<span class="v">$2</span><span class="o">**</span><span class="n">2</span>) notitle w yerrorb ls <span class="n">1</span>, \
     <span class="s">''</span>               i <span class="n">2</span> u (<span class="v">$0</span><span class="o">+</span><span class="v">bs</span>):<span class="n">1</span>:(<span class="v">bs</span>) t <span class="s">'C'</span> w boxes ls <span class="n">4</span>
</pre>
]]></content:encoded>
					
					<wfw:commentRss>./../../../plotting-more-advanced-statistical-data/feed/index.html</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>Plotting simple statistical data</title>
		<link>./../../../plotting-simple-statistical-data/index.html</link>
					<comments>./../../../plotting-simple-statistical-data/index.html#respond</comments>
		
		<dc:creator><![CDATA[hagen]]></dc:creator>
		<pubDate>Thu, 09 Sep 2010 15:03:56 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ANOVA]]></category>
		<category><![CDATA[border]]></category>
		<category><![CDATA[boxes]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[errorbars]]></category>
		<category><![CDATA[xticlabel]]></category>
		<guid isPermaLink="false">./../../../index.html?p=444</guid>

					<description><![CDATA[If we have done a experiment in order to apply a significance test like a ANOVA to our measured data, we are interested in presenting our statistical data in a familiar way. Let us assume we have the following mean and standard deviation data for five different conditions: "A" 0.66257 0.41854 "B" 0.70842 0.38418 "C" [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>If we have done a experiment in order to apply a significance test like a ANOVA to our measured data, we are interested in presenting our statistical data in a familiar way.<br />
Let us assume we have the following mean and standard deviation data for five different conditions:</p>
<pre>
"A"     0.66257     0.41854
"B"     0.70842     0.38418
"C"     0.66733     0.44059
"D"     0.45375     0.52384
"E"     0.43900     0.53116
</pre>
<p>The results for the last two conditions are significant different from the first ones. Using this data we want to create a plot that looks like the one in Fig. 1.</p>
<div class="figure">
    <object data="./../../../figs/simple_statistics.svg" type="image/svg+xml"><img decoding="async" src="./../../../figs/simple_statistics.png" alt="mean and variance" width="350"/></object></p>
<p class="caption">
        <strong>Fig. 1 </strong>Plot the mean and variance of the given <a href="./../../../data/simple_statistics.dat">data</a> (<a href="./../../../code/simple_statistics.gnu" type="text/plain">code to produce this figure</a>)
    </p>
</div>
<p>To achieve the plot in Fig. 1 we have to define two different color styles for the color of the errorbars and the color of the boxes. Also, we need the fill style (<code>solid</code>) for the boxes and the gray line around the boxes which is given by the <code>border rgb 'grey30'</code> option to the <code>set style fill</code> command. For the line color we choose the same color as for the errorbars:</p>
<pre class="prettyprint">
<span class="k">set</span> style line <span class="n">1</span> lc rgb <span class="s">'grey30'</span> ps <span class="n">0</span> lt <span class="n">1</span> lw <span class="n">2</span>
<span class="k">set</span> style line <span class="n">2</span> lc rgb <span class="s">'grey70'</span> lt <span class="n">1</span> lw <span class="n">2</span>
<span class="k">set</span> style fill solid <span class="n">1.0</span> border rgb <span class="s">'grey30'</span>
</pre>
<p>For the first line style which is used to plot the errorbars also a point size of <code>0</code> is specified in order to plot only the errorbars and no points on top of the boxes.</p>
<p>The <code>*</code>-dots above the two last conditions to indicate their significant difference are just added as labels. The border of the graph on the top and right side is removed by <code>set border 3</code> (<a href="http://www.gnuplot.info/docs_4.4/gnuplot.html#x1-18400075.7">see here for an explanation of the number codes</a>) and by using the <code>nomirror</code> option for the tics. The xtics are not visible, because we set them to <code>scale 0</code>.</p>
<pre class="prettyprint">
<span class="k">set</span> label <span class="s">'*'</span> at <span class="n">3</span>,<span class="n">0.8</span> center
<span class="k">set</span> label <span class="s">'*'</span> at <span class="n">4</span>,<span class="n">0.8</span> center
<span class="k">set</span> border <span class="n">3</span>
<span class="k">set</span> xtics nomirror scale <span class="n">0</span>
<span class="k">set</span> ytics nomirror out scale <span class="n">0.75</span> <span class="n">0.5</span>
</pre>
<p>Then we plot first the errorbars in order to overlay the boxes on it, so only the top half of the errorbars will be visible. Note that we have standard deviation data in the data file, therefore we have to use their squares in order to get the variance. As xtic labels we use the first row in the data file by appending <code>xtic(1)</code>:</p>
<pre class="prettyprint">
<span class="k">plot</span> <span class="s">'simple_statistics.dat'</span> u <span class="n">0</span>:<span class="n">2</span>:(<span class="v">$3</span><span class="o">**</span><span class="n">2</span>) w yerrorbars ls <span class="n">1</span>, \
     <span class="s">''</span>                      u <span class="n">0</span>:<span class="n">2</span>:(<span class="n">0.7</span>):xtic(<span class="n">1</span>) w boxes ls <span class="n">2</span>
</pre>
]]></content:encoded>
					
					<wfw:commentRss>./../../../plotting-simple-statistical-data/feed/index.html</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
