<?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>splot &#8211; Gnuplotting</title>
	<atom:link href="./index.html?simply_static_page=2066" 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>Plotting raster data from Natural Earth</title>
		<link>./../../../plotting-raster-data-from-natural-earth/index.html</link>
					<comments>./../../../plotting-raster-data-from-natural-earth/index.html#comments</comments>
		
		<dc:creator><![CDATA[hagen]]></dc:creator>
		<pubDate>Fri, 31 Jan 2014 22:41:54 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[angles]]></category>
		<category><![CDATA[datafile]]></category>
		<category><![CDATA[pm3d]]></category>
		<category><![CDATA[rgb]]></category>
		<category><![CDATA[rgbimage]]></category>
		<category><![CDATA[sphere]]></category>
		<category><![CDATA[splot]]></category>
		<category><![CDATA[tif]]></category>
		<category><![CDATA[variable]]></category>
		<guid isPermaLink="false">./../../../index.html?p=1877</guid>

					<description><![CDATA[And another plot of the world. This time we are dealing with the raster data from Natural Earth. This data is normally available as tif-files. To use them in gnuplot we have to convert them first, then we can create a plot as shown in Fig. 1. Fig. 1 Cross-blended hypsometric tint plot of the [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>And <a href="./../../../plotting-the-world-revisited/index.html">another</a> plot of the world. This time we are dealing with the <a href="http://www.naturalearthdata.com/downloads/50m-raster-data/">raster data</a> from Natural Earth. This data is normally available as tif-files. To use them in gnuplot we have to convert them first, then we can create a plot as shown in Fig. 1.</p>
<div class="figure">
    <img decoding="async" src="./../../../figs/world_color.png" alt="Cross-blended Hypsometric Tints"/></p>
<p class="caption">
        <strong>Fig. 1 </strong> Cross-blended hypsometric tint plot of the world. (<a href="./../../../code/world_color.gnu" type="text/plain" rel="nofollow">code to produce this figure</a>, <a href="./../../../data/HYP_50M_SR_W_350px.txt" rel="nofollow">data</a>)
    </p>
</div>
<p>The conversion is done by the <a href="./../../../code/convert_natural_earth/index.html">convert_natural_earth</a> script. There the tif-file is first scaled down to the desired resolution using <a href="http://www.imagemagick.org/">imagemagick</a>. Afterwards it is converted to a text file and reordered for the <code>splot</code> command of gnuplot. The text file includes the longitude, latitude and three rgb color values.<br />
You have to invoke the script in the following way.</p>
<pre class="prettyprint">
$ ./convert_natural_earth $RES $FILE
</pre>
<p>where <code>$RES</code> is the desired resolution in pixel of your gnuplot plot and <code>$FILE</code> the input tif-file.<br />
After finished we can plot the resulting text file simply by</p>
<pre class="prettyprint">
set datafile separator ','
set size ratio -1
plot 'HYP_50M_SR_W_350px.txt' w rgbimage
</pre>
<p>which results in Fig. 1.</p>
<div class="figure">
    <img decoding="async" src="./../../../figs/world_color_3d.png" alt="Natural Earth II Shaded Relief and Water"/></p>
<p class="caption">
        <strong>Fig. 2 </strong> Natural Earth II shaded relief and water plot of the world. (<a href="./../../../code/world_color_3d.gnu" type="text/plain" rel="nofollow">code to produce this figure</a>, <a href="./../../../data/NE2_50M_SR_W_700px.txt" rel="nofollow">data</a>)
    </p>
</div>
<p>The image can also be projected on a 3D figure of the world as shown in Fig. 2. To achieve this the three rgb values have to be summarized in one value and the <code>rgb variable</code> line color option has to be chosen together with <code>pm3d</code>.</p>
<pre class="prettyprint">
rgb(r,g,b) = 65536 * int(r) + 256 * int(g) + int(b)
set mapping spherical
set angles degrees
splot 'NE2_50M_SR_W_700px.txt' u 1:2:(1):(rgb($3,$4,$5)) w pm3d lc rgb variable
</pre>
]]></content:encoded>
					
					<wfw:commentRss>./../../../plotting-raster-data-from-natural-earth/feed/index.html</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Plotting cubes</title>
		<link>./../../../plotting-cubes/index.html</link>
					<comments>./../../../plotting-cubes/index.html#comments</comments>
		
		<dc:creator><![CDATA[hagen]]></dc:creator>
		<pubDate>Thu, 22 Aug 2013 09:27:23 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cube]]></category>
		<category><![CDATA[eval]]></category>
		<category><![CDATA[hidden3d]]></category>
		<category><![CDATA[implicit]]></category>
		<category><![CDATA[pm3d]]></category>
		<category><![CDATA[splot]]></category>
		<category><![CDATA[sprintf]]></category>
		<category><![CDATA[stats]]></category>
		<guid isPermaLink="false">./../../../index.html?p=1809</guid>

					<description><![CDATA[On the PGF plots page I found a nice example of visualizing data with cubes. Here we will recreate the same with gnuplot as you can see in Fig. 1. Fig. 1 Cubes with different colors. (code to produce this figure, cube function, data) We need basically two things in order to achieve it. First [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>On the <a href="http://pgfplots.sourceforge.net/">PGF plots page</a> I found a nice example of visualizing data with cubes. Here we will recreate the same with gnuplot as you can see in Fig. 1.</p>
<div class="figure">
    <img decoding="async" src="./../../../figs/cube.png" alt="Cubes"/></p>
<p class="caption">
        <strong>Fig. 1 </strong> Cubes with different colors. (<a href="./../../../code/cube.gnu" type="text/plain" rel="nofollow">code to produce this figure</a>, <a href="./../../../code/cube.fct" rel="nofollow">cube function</a>, <a href="./../../../data/cube_positions.txt" rel="nofollow">data</a>)
    </p>
</div>
<p>We need basically two things in order to achieve it. First we have to plot a single cube with gnuplot. This is not as straight forward as you may think. We have to define a data file for it and plot it with the <code>pm3d</code> style which will result in Fig. 2.</p>
<pre>
# single cube
0 0 0
0 0 1
0 1 1
0 1 0
0 0 0

1 0 0
1 0 1
1 1 1
1 1 0
1 0 0

0 0 0
1 0 0
1 1 0
0 1 0
0 0 0

0 0 1
1 0 1
1 1 1
0 1 1
0 0 1
</pre>
<pre class="prettyprint">
set cbrange [0.9:1]
set palette defined (1 '#ce4c7d')
set style line 1 lc rgb '#b90046' lt 1 lw 0.5
set pm3d depthorder hidden3d
set pm3d implicit
unset hidden3d
splot 'cube.txt' u 1:2:3:(1) w l ls 1
</pre>
<p>The use of the fourth <code>(1)</code> column for the <code>splot</code> command ensures that the cube gets the same color on every side. Only the edges are highlighted by a slighty different color given by the line style.</p>
<div class="figure">
    <img decoding="async" src="./../../../figs/single_cube.png" alt="A single cube"/></p>
<p class="caption">
        <strong>Fig. 2 </strong>A single cube. (<a href="./../../../code/single_cube.gnu" type="text/plain" rel="nofollow">code to produce this figure</a>, <a href="./../../../data/cube.txt" rel="nofollow">data</a>)
    </p>
</div>
<p>In a second step we reuse the code from the <a href="./../../../object-placement-using-a-data-file/index.html">Object placement using a data file</a> entry in order to plot cubes at different positions with different colors. To get the different colors and positions we replace the cube.txt file with a <a href="./../../../code/cube.fct">cube function</a> that returns the values for the desired position and color.</p>
<pre class="prettyprint">
add_cube(x,y,z,c) = sprintf('cube(%f,%f,%f,%i) w l ls %i,',x,y,z,c,c)
CMD = ''
stats 'cube_positions.txt' u 1:(CMD = CMD.add_cube($1,$2,$3,$4)) nooutput
CMD = 'splot '.CMD.'1/0 w l ls 2'
eval(CMD)
</pre>
]]></content:encoded>
					
					<wfw:commentRss>./../../../plotting-cubes/feed/index.html</wfw:commentRss>
			<slash:comments>30</slash:comments>
		
		
			</item>
		<item>
		<title>Interpolation of heat maps</title>
		<link>./../../../interpolation-of-heat-maps/index.html</link>
					<comments>./../../../interpolation-of-heat-maps/index.html#comments</comments>
		
		<dc:creator><![CDATA[hagen]]></dc:creator>
		<pubDate>Tue, 12 Mar 2013 20:46:47 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[colormap]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[interpolate]]></category>
		<category><![CDATA[matrix]]></category>
		<category><![CDATA[pm3d]]></category>
		<category><![CDATA[splot]]></category>
		<guid isPermaLink="false">./../../../index.html?p=1682</guid>

					<description><![CDATA[We discussed already the plotting of heat maps at more than one occasions. Here we will add the possibility to interpolate the data in a heat map figure. Fig. 1 A simple heat map (code to produce this figure, data) Suppose we have the following data matrix, stored in heat_map_data.txt. 6 5 4 3 1 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>We discussed already the plotting <a href="./../../../heat-maps/index.html">of heat maps</a> at <a href="./../../../color-maps-and-the-scale-of-axes/index.html">more than</a> one <a href="./../../../matlab-colorbar-with-gnuplot/index.html">occasions</a>. Here we will add the possibility to interpolate the data in a heat map figure.</p>
<div class="figure">
        <img decoding="async" src="./../../../figs/heat_map_interpolation1.png" alt="Heat map" width="350"/></p>
<p class="caption">
        <strong>Fig. 1 </strong>A simple heat map (<a href="./../../../code/heat_map_interpolation1.gnu" type="text/plain">code to produce this figure</a>, <a href="./../../../data/heat_map_data.txt" type="text/plain">data</a>)
    </p>
</div>
<p>Suppose we have the following data matrix, stored in <a href="./../../../data/heat_map_data.txt">heat_map_data.txt</a>.</p>
<pre>
6 5 4 3 1 0
3 2 2 0 0 1
0 0 0 0 1 0
0 0 0 0 2 3
0 0 1 2 4 3
0 1 2 3 4 5
</pre>
<p>The normal way of plotting them would be with</p>
<pre class="prettyprint">
plot 'heat_map_data.txt' matrix with image
</pre>
<p>But to be able to interpolate the data we have to use <a href="./../../../manpage-gnuplot-4-6/index.html#x1-370000III" class="manpage">splot</a> and <a href="./../../../manpage-gnuplot-4-6/index.html#x1-265000III" class="manpage">pm3d</a> instead. </p>
<pre class="prettyprint">
set pm3d map
splot 'heat_map_data.txt' matrix
</pre>
<p>In Fig. 1 the result of plotting the data just with splot, without interpolation is shown. Note, that the result differs already from the plot command. The plot command would have created six points, whereas the splot command comes up with only five different regions for every axis.</p>
<div class="figure">
        <img decoding="async" src="./../../../figs/heat_map_interpolation2.png" alt="Interpolated heat map" width="350"/></p>
<p class="caption">
        <strong>Fig. 2 </strong>A heat map interpolated to use twice as much points on every axis (<a href="./../../../code/heat_map_interpolation2.gnu" type="text/plain">code to produce this figure</a>, <a href="./../../../data/heat_map_data.txt" type="text/plain">data</a>)
    </p>
</div>
<p>Now if we want to double the number of visible points, we can tell pm3d easily to interpolate the data by the <a href="./../../../manpage-gnuplot-4-6/index.html#x1-272000III" class="manpage">interpolate</a> command.</p>
<pre class="prettyprint">
set pm3d interpolate 2,2
</pre>
<p>The two numbers <code>2,2</code> are the number of additional points along the x- and y-axis.<br />
The resulting plot can be found in Fig. 2.</p>
<div class="figure">
        <img decoding="async" src="./../../../figs/heat_map_interpolation3.png" alt="Strong interpolated heat map" width="350"/></p>
<p class="caption">
        <strong>Fig. 3 </strong>A heat map interpolated with an optimal number of points (<a href="./../../../code/heat_map_interpolation3.gnu" type="text/plain">code to produce this figure</a>, <a href="./../../../data/heat_map_data.txt" type="text/plain">data</a>)
    </p>
</div>
<p>In addition to explicitly setting the number of points we can tell gnuplot to choose the correct number of interpolation points by itself, by setting them to 0.</p>
<pre class="prettyprint">
set pm3d interpolate 0,0
</pre>
<p>Now gnuplot decides by itself how to interpolate, which leads to the result in Fig. 3.</p>
]]></content:encoded>
					
					<wfw:commentRss>./../../../interpolation-of-heat-maps/feed/index.html</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
			</item>
		<item>
		<title>Animation IV &#8211; trajectory</title>
		<link>./../../../animation-iv-trajectory/index.html</link>
					<comments>./../../../animation-iv-trajectory/index.html#comments</comments>
		
		<dc:creator><![CDATA[hagen]]></dc:creator>
		<pubDate>Wed, 07 Nov 2012 22:34:34 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[do]]></category>
		<category><![CDATA[gif]]></category>
		<category><![CDATA[splot]]></category>
		<guid isPermaLink="false">./../../../index.html?p=1523</guid>

					<description><![CDATA[Assume you have a data file describing a trajectory that you would like to animate like the spiral shown in Fig. 1. Fig. 1 An animated spiral trajectory (code to produce this figure, data) In order to create the animation we have to produce a set of png images and create the resulting gif animation [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Assume you have a data file describing a trajectory that you would like to animate like the spiral shown in Fig. 1.</p>
<div class="figure">
    <img decoding="async" src="./../../../figs/spiral.gif" alt="moving spiral"/></p>
<p class="caption">
        <strong>Fig. 1 </strong>An animated spiral trajectory (<a href="./../../../code/spiral.gnu" type="text/plain">code to produce this figure</a>, <a href="./../../../data/spiral.txt">data</a>)
    </p>
</div>
<p>In order to create the animation we have to produce a set of png images and create the resulting gif animation with GIMP as shown in the <a href="./../../../animation-gif/index.html">Animation I – gif</a> entry. Therefor, we have to tell gnuplot at which point of the data it has to stop for each image. This can be achieved by the <code>every</code> option. The point at the end of the line is just one data point. Here the start point and end point for <code>every</code> are just the same.</p>
<pre class="prettyprint">
do for [ii=1:99] {
    splot 'spiral.txt' every ::1::ii w l ls 1, \
          'spiral.txt' every ::ii::ii w p ls 1
}
</pre>
<p>The downward spiral is created by running the loop in the other direction.</p>
<pre class="prettyprint">
do for [ii=99:1:-1] {
    splot 'spiral.txt' every ::1::ii w l ls 1, \
          'spiral.txt' every ::ii::ii w p ls 1
}
</pre>
<p>By the way, I don&#8217;t know why the antialiasing of the output png images is not working in this example. If you have any idea, feel free to tell me.Assume you have a data file describing a trajectory that you would like to animate like the spiral shown in Fig. 1.</p>
]]></content:encoded>
					
					<wfw:commentRss>./../../../animation-iv-trajectory/feed/index.html</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
		<item>
		<title>Plot functions using the special-filenames property</title>
		<link>./../../../plot-functions-using-the-special-filenames-property/index.html</link>
					<comments>./../../../plot-functions-using-the-special-filenames-property/index.html#comments</comments>
		
		<dc:creator><![CDATA[hagen]]></dc:creator>
		<pubDate>Fri, 08 Jul 2011 13:00:10 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[+]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[samples]]></category>
		<category><![CDATA[special-filenames]]></category>
		<category><![CDATA[splot]]></category>
		<guid isPermaLink="false">./../../../index.html?p=950</guid>

					<description><![CDATA[The last entry has plotted all its data from data files, even the signal at 700Hz. In this entry we will see how to plot the signal as a function using the special-filenames property of Gnuplot. Fig. 1 Visualization of the comodulation masking release using splot and special-filenames (code to produce this figure, gfb_loop.gnu, gfb.dat, [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>The <a href="./../../../splot-filledcurves/index.html">last entry</a> has plotted all its data from data files, even the signal at 700Hz. In this entry we will see how to plot the signal as a function using the <code>special-filenames</code> property of Gnuplot.</p>
<div class="figure">
    <img decoding="async" src="./../../../figs/cmr2.png" alt="CMR" width="350"/></p>
<p class="caption">
        <strong>Fig. 1 </strong>Visualization of the comodulation masking release using splot and special-filenames (<a href="./../../../code/cmr2.gnu" type="text/plain">code to produce this figure</a>, <a href="./../../../code/gfb_loop.gnu" type="text/plain">gfb_loop.gnu</a>, <a href="./../../../data/gfb.dat">gfb.dat</a>, <a href="./../../../data/noise.dat">noise.dat</a>)
    </p>
</div>
<p>In Fig. 1 the end result is seen. What we have done is to replace the last <code>splot</code> command from the <a href="./../../../code/cmr.gnu">cmr.gnu</a> file with the following code.</p>
<pre class="prettyprint">
<span class="k">set</span> samples <span class="n">500</span>
<span class="C"># Define the sinusoid signal to be plotted</span>
<span class="f">sig</span>(<span class="v">y</span>) <span class="o">=</span> <span class="v">y</span><span class="o">&gt;</span><span class="n">0.1</span> <span class="o">&&</span> <span class="v">y</span><span class="o">&lt;</span><span class="n">0.4</span> <span class="o">?</span> <span class="n">0.45</span><span class="o">*</span><span class="f">sin</span>(<span class="n">2</span><span class="o">*</span><span class="c">pi</span><span class="o">*</span><span class="n">100</span><span class="o">*</span><span class="v">y</span>)<span class="o">+</span><span class="n">2</span> : <span class="n">2</span>
<span class="C"># The desired range is 0:0.5, but the samples were created for the
# x-axis, which has a range of 0:1400, therefore we calculate an
# factor to do the plot</span>
<span class="v">fact</span> <span class="o">=</span> <span class="n">1400</span><span class="o">/</span><span class="n">0.5</span>
<span class="k">splot</span> <span class="s">'+'</span> u (<span class="n">700</span>):(<span class="v">$1</span><span class="o">/</span><span class="v">fact</span>):(<span class="f">sig</span>(<span class="v">$1</span><span class="o">/</span><span class="v">fact</span>)) w l ls <span class="n">14</span>
</pre>
<p>We define the function <code>sig(y)</code> which is a 100Hz sinusoid centered at 2 for values of y between 0.1 and 0.4 and constant 2 else. In order to place this two dimensional function in our 3D plot we use the <code>special-filenames</code> property from Gnuplot, in this case the <code>'+'</code> variant. This tells Gnuplot to use the xrange, apply a sampling of it and return it as first column for the plot command. But for our plot we need the y-axis and not the x-axis, because the x values should be constant at 700 and are therefore given by <code>(700)</code> at the <code>splot</code> command. The values of the first column, given by <code>$1</code> are scaled by <code>fact</code> in order to match the two axis and are then directly used as y values and given to the <code>sig(y)</code> function for the z values.</p>
]]></content:encoded>
					
					<wfw:commentRss>./../../../plot-functions-using-the-special-filenames-property/feed/index.html</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Filledcurves with splot</title>
		<link>./../../../splot-filledcurves/index.html</link>
					<comments>./../../../splot-filledcurves/index.html#respond</comments>
		
		<dc:creator><![CDATA[hagen]]></dc:creator>
		<pubDate>Fri, 24 Jun 2011 08:35:25 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[call]]></category>
		<category><![CDATA[filledcurves]]></category>
		<category><![CDATA[iteration]]></category>
		<category><![CDATA[reread]]></category>
		<category><![CDATA[splot]]></category>
		<guid isPermaLink="false">./../../../index.html?p=442</guid>

					<description><![CDATA[The filledcurves style is only available for 2d plots. But it can be used with some limitations with splot in 3d plots as well. In this entry we want to visualize an effect known from psychoacoustics, called comodulation masking release. The effect describes the possibility of our hearing system to perceive a masked tone (in [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>The <code>filledcurves</code> style is only available for 2d plots. But it can be used with some limitations with splot in 3d plots as well. In this entry we want to visualize an effect known from psychoacoustics, called comodulation masking release. The effect describes the possibility of our hearing system to perceive a masked tone (in this case at 700 Hz) easier in the presence of so called comodulated maskers present in other auditory filters. Comodulation describes the fact, that all maskers have the same envelope, as can be seen in Fig. 1.</p>
<div class="figure">
    <img decoding="async" src="./../../../figs/cmr.png" alt="CMR" width="350"/></p>
<p class="caption">
        <strong>Fig. 1 </strong>Visualization of the comodulation masking release using splot and filledcurves (<a href="./../../../code/cmr.gnu" type="text/plain">code to produce this figure</a>, <a href="./../../../code/gfb_loop.gnu" type="text/plain">gfb_loop.gnu</a>, <a href="./../../../data/gfb.dat">gfb.dat</a>, <a href="./../../../data/sig.dat">sig.dat</a>, <a href="./../../../data/noise.dat">noise.dat</a>)
    </p>
</div>
<p>First we start with the <a href="http://en.wikipedia.org/wiki/Gammatone_filter">gammatone filters</a>. The values for them are stored in the <a href="./../../../data/gfb.dat">gfb.dat</a> file as one column per filter. In order to apply different colors to different filters the style function <code>sty(x)</code> is defined. The <code>data(x)</code> function is defined to be able to plot the filters in a particular order. This will result in the nice effect of overlapping filters shown in Fig. 2.</p>
<pre class="prettyprint">
<span class="f">sty</span>(<span class="v">x</span>) <span class="o">=</span> <span class="v">x</span><span class="o">&lt;</span><span class="n">7</span> <span class="o">?</span> <span class="n">1</span> <span class="o">:</span> <span class="v">x</span><span class="o">&lt;</span><span class="n">10</span> <span class="o">?</span> <span class="n">2</span> <span class="o">:</span> <span class="v">x</span><span class="o">&lt;</span><span class="n">12</span> <span class="o">?</span> <span class="n">1</span> <span class="o">:</span> <span class="v">x</span><span class="o">==</span><span class="n">12</span> <span class="o">?</span> <span class="n">3</span> <span class="o">:</span> <span class="v">x</span><span class="o">&lt;</span><span class="n">15</span> <span class="o">?</span> <span class="n">1</span> <span class="o">:</span> \
    <span class="v">x</span><span class="o">==</span><span class="n">15</span> <span class="o">?</span> <span class="n">2</span> <span class="o">:</span> <span class="n">1</span>
<span class="f">data</span>(<span class="v">x</span>) <span class="o">=</span> <span class="v">x</span><span class="o">&lt;</span><span class="n">12</span> <span class="o">?</span> <span class="v">x</span> <span class="o">:</span> <span class="n">29</span><span class="o">-</span><span class="v">x</span>
</pre>
<p>The filter bank itself is plotted by the <code>gfb_loop.gnu</code> function. There the data are plotted first as filledcurves and then as a line. This two step mechanism has to be used, because the <code>filledcurves</code> style is not able to draw an extra line in 3d. Hence it has to be done in the extra <code>gfb_loop.gnu</code> function, because the simple <code>for</code> iteration only works for a single plot and is not able to plot the line around the filters.</p>
<pre class="prettyprint">
<span class="C"># gfb_loop.gnu</span>
<span class="k">splot</span> <span class="s">&#39;gfb.dat&#39;</span> <span class="nb">u</span> <span class="n">2</span><span class="o">:</span><span class="n">1</span><span class="o">:</span><span class="p">(</span><span class="f">column</span><span class="p">(</span><span class="f">data</span><span class="p">(</span><span class="v">i</span><span class="p">)))</span> <span class="nb">w</span> <span class="nn">filledcurves</span> \
    <span class="nn">ls</span> <span class="f">sty</span><span class="p">(</span><span class="f">data</span><span class="p">(</span><span class="v">i</span><span class="p">))</span><span class="o">,</span> \
      <span class="s">&#39;&#39;</span>        <span class="nb">u</span> <span class="n">2</span><span class="o">:</span><span class="n">1</span><span class="o">:</span><span class="p">(</span><span class="f">column</span><span class="p">(</span><span class="f">data</span><span class="p">(</span><span class="v">i</span><span class="p">)))</span> <span class="nn">ls</span> <span class="n">4</span>
<span class="v">i</span> <span class="o">=</span> <span class="v">i</span><span class="o">+</span><span class="n">1</span>
<span class="k">if</span> <span class="p">(</span><span class="v">i</span><span class="o">&lt;</span><span class="v">maxi</span><span class="p">)</span> <span class="k">reread</span>
</pre>
<div class="figure">
    <img decoding="async" src="./../../../figs/cmr1.png" alt="CMR" width="350"/></p>
<p class="caption">
        <strong>Fig. 2 </strong>Plotting gammatone filters with an extra loop file (<a href="./../../../code/cmr1.gnu" type="text/plain">code to produce this figure</a>, <a href="./../../../code/gfb_loop.gnu" type="text/plain">gfb_loop.gnu</a>, <a href="./../../../data/gfb.dat">gfb.dat</a>)
    </p>
</div>
<p>Thereafter the modulated noise and its envelope and the signal are plotted in different parts of the graph by explicitly giving the x position.<br />
The result is shown in Fig. 1.</p>
<pre class="prettyprint">
<span class="k">splot</span> <span class="s">&#39;noise.dat&#39;</span> <span class="nb">u</span>  <span class="p">(</span><span class="n">300</span><span class="p">)</span><span class="o">:</span><span class="n">1</span><span class="o">:</span><span class="n">2</span> ls <span class="n">11</span><span class="o">,</span> \
      <span class="s">&#39;&#39;</span>          <span class="nb">u</span>  <span class="p">(</span><span class="n">300</span><span class="p">)</span><span class="o">:</span><span class="n">1</span><span class="o">:</span><span class="n">3</span> ls <span class="n">14</span><span class="o">,</span> \
      <span class="s">&#39;&#39;</span>          <span class="nb">u</span>  <span class="p">(</span><span class="n">400</span><span class="p">)</span><span class="o">:</span><span class="n">1</span><span class="o">:</span><span class="n">2</span> ls <span class="n">12</span><span class="o">,</span> \
      <span class="s">&#39;&#39;</span>          <span class="nb">u</span>  <span class="p">(</span><span class="n">400</span><span class="p">)</span><span class="o">:</span><span class="n">1</span><span class="o">:</span><span class="n">3</span> ls <span class="n">14</span><span class="o">,</span> \
      <span class="s">&#39;&#39;</span>          <span class="nb">u</span>  <span class="p">(</span><span class="n">700</span><span class="p">)</span><span class="o">:</span><span class="n">1</span><span class="o">:</span><span class="n">2</span> ls <span class="n">13</span><span class="o">,</span> \
      <span class="s">&#39;&#39;</span>          <span class="nb">u</span>  <span class="p">(</span><span class="n">700</span><span class="p">)</span><span class="o">:</span><span class="n">1</span><span class="o">:</span><span class="n">3</span> ls <span class="n">14</span><span class="o">,</span> \
      <span class="s">&#39;&#39;</span>          <span class="nb">u</span> <span class="p">(</span><span class="n">1000</span><span class="p">)</span><span class="o">:</span><span class="n">1</span><span class="o">:</span><span class="n">2</span> ls <span class="n">12</span><span class="o">,</span> \
      <span class="s">&#39;&#39;</span>          <span class="nb">u</span> <span class="p">(</span><span class="n">1000</span><span class="p">)</span><span class="o">:</span><span class="n">1</span><span class="o">:</span><span class="n">3</span> ls <span class="n">14</span><span class="o">,</span> \
      <span class="s">&#39;&#39;</span>          <span class="nb">u</span> <span class="p">(</span><span class="n">1100</span><span class="p">)</span><span class="o">:</span><span class="n">1</span><span class="o">:</span><span class="n">2</span> ls <span class="n">11</span><span class="o">,</span> \
      <span class="s">&#39;&#39;</span>          <span class="nb">u</span> <span class="p">(</span><span class="n">1100</span><span class="p">)</span><span class="o">:</span><span class="n">1</span><span class="o">:</span><span class="n">3</span> ls <span class="n">14</span>
<span class="k">splot</span> <span class="s">&#39;sig.dat&#39;</span>   <span class="nb">u</span> <span class="p"> (</span><span class="n">700</span><span class="p">)</span><span class="o">:</span><span class="n">1</span><span class="o">:</span><span class="n">2</span> ls <span class="n">14</span>
</pre>
]]></content:encoded>
					
					<wfw:commentRss>./../../../splot-filledcurves/feed/index.html</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Klein bottle</title>
		<link>./../../../klein-bottle/index.html</link>
					<comments>./../../../klein-bottle/index.html#comments</comments>
		
		<dc:creator><![CDATA[hagen]]></dc:creator>
		<pubDate>Tue, 07 Jun 2011 14:05:04 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[depthorder]]></category>
		<category><![CDATA[hidden3d]]></category>
		<category><![CDATA[parametric]]></category>
		<category><![CDATA[pm3d]]></category>
		<category><![CDATA[splot]]></category>
		<category><![CDATA[transparent]]></category>
		<guid isPermaLink="false">./../../../index.html?p=410</guid>

					<description><![CDATA[A Klein bottle is a non-orientable surface, which has no defined left and right, as stated on Wikipedia. There we can also find a Gnuplot plot of the bottle, which we want to fine-tune a little bit in order to reach the result in Fig. 1. Fig. 1 Klein bottle (code to produce this figure) [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>A <a href="http://en.wikipedia.org/wiki/Klein_bottle">Klein bottle</a> is a non-orientable surface, which has no defined left and right, as stated on Wikipedia. There we can also find a <a href="http://en.wikipedia.org/wiki/File:Klein_bottle.svg">Gnuplot plot of the bottle</a>, which we want to fine-tune a little bit in order to reach the result in Fig. 1.</p>
<div class="figure">
    <img decoding="async" src="./../../../figs/klein_bottle.png" alt="Klein bottle" width="350"/></p>
<p class="caption">
        <strong>Fig. 1 </strong>Klein bottle (<a href="./../../../code/klein_bottle.gnu" type="text/plain">code to produce this figure</a>)
    </p>
</div>
<p>In order to reach Fig. 1 we start with the definition of the parametric functions given in Wikipedia and do a simple <code>pm3d</code> plot with them.</p>
<pre class="prettyprint">
<span class="k">set</span> <span class="nb">parametric</span>
<span class="f">x</span>(<span class="v">u</span>,<span class="v">v</span>)<span class="o">=</span> <span class="v">v</span><span class="o">&lt;</span><span class="n">2</span><span class="o">*</span><span class="c">pi</span> <span class="o">?</span> <span class="p">(</span><span class="n">2.5</span><span class="n">-1</span><span class="n">.5</span><span class="o">*</span><span class="f">cos</span><span class="p">(</span><span class="v">v</span><span class="p">))</span><span class="o">*</span><span class="f">cos</span><span class="p">(</span><span class="v">u</span><span class="p">)</span><span class="o"> :</span> \
        <span class="v">v</span><span class="o">&lt;</span><span class="n">3</span><span class="o">*</span><span class="c">pi</span> <span class="o">?</span> <span class="n">-2</span><span class="o">+</span><span class="p">(</span><span class="n">2</span><span class="o">+</span><span class="f">cos</span><span class="p">(</span><span class="v">u</span><span class="p">))</span><span class="o">*</span><span class="f">cos</span><span class="p">(</span><span class="v">v</span><span class="p">)</span><span class="o">    :</span> \
                 <span class="n">-2</span><span class="o">+</span><span class="n">2</span><span class="o">*</span><span class="f">cos</span><span class="p">(</span><span class="v">v</span><span class="p">)</span><span class="o">-</span><span class="f">cos</span><span class="p">(</span><span class="v">u</span><span class="p">)</span>
<span class="f">y</span>(<span class="v">u</span>,<span class="v">v</span>)<span class="o">=</span> <span class="v">v</span><span class="o">&lt;</span><span class="n">2</span><span class="o">*</span><span class="c">pi</span> <span class="o">?</span> <span class="p">(</span><span class="n">2.5</span><span class="n">-1</span><span class="n">.5</span><span class="o">*</span><span class="f">cos</span><span class="p">(</span><span class="v">v</span><span class="p">))</span><span class="o">*</span><span class="f">sin</span><span class="p">(</span><span class="v">u</span><span class="p">)</span><span class="o"> :</span> \
                <span class="f">sin</span><span class="p">(</span><span class="v">u</span><span class="p">)</span>
<span class="f">z</span>(<span class="v">u</span>,<span class="v">v</span>)<span class="o">=</span> <span class="v">v</span><span class="o">&lt;</span><span class="c">pi</span>   <span class="o">?</span> <span class="n">-2</span><span class="n">.5</span><span class="o">*</span><span class="f">sin</span><span class="p">(</span><span class="v">v</span><span class="p">)</span><span class="o">             :</span> \
        <span class="v">v</span><span class="o">&lt;</span><span class="n">2</span><span class="o">*</span><span class="c">pi</span> <span class="o">?</span> <span class="n">3</span><span class="o">*</span><span class="v">v</span><span class="n">-3</span><span class="o">*</span><span class="c">pi</span><span class="o">                :</span> \
        <span class="v">v</span><span class="o">&lt;</span><span class="n">3</span><span class="o">*</span><span class="c">pi</span> <span class="o">?</span> <span class="p">(</span><span class="n">2</span><span class="o">+</span><span class="f">cos</span><span class="p">(</span><span class="v">u</span><span class="p">))</span><span class="o">*</span><span class="f">sin</span><span class="p">(</span><span class="v">v</span><span class="p">)</span><span class="o">+</span><span class="n">3</span><span class="o">*</span><span class="c">pi</span><span class="o">  :</span> \
                 <span class="n">-3</span><span class="o">*</span><span class="v">v</span><span class="o">+</span><span class="n">12</span><span class="o">*</span><span class="c">pi</span>
<span class="k">splot</span> <span class="f">x</span><span class="p">(</span><span class="v">u</span><span class="o">,</span><span class="v">v</span><span class="p">)</span><span class="o">,</span><span class="f">y</span><span class="p">(</span><span class="v">u</span><span class="o">,</span><span class="v">v</span><span class="p">)</span><span class="o">,-</span><span class="f">z</span><span class="p">(</span><span class="v">u</span><span class="o">,</span><span class="v">v</span><span class="p">)</span> <span class="nb">w</span> <span class="nb">pm3d</span>
</pre>
<p>The result is shown in Fig. 2.</p>
<div class="figure">
    <img decoding="async" src="./../../../figs/klein_bottle1.png" alt="Klein bottle" width="350"/></p>
<p class="caption">
        <strong>Fig. 2 </strong>Klein bottle plotted only with pm3d (<a href="./../../../code/klein_bottle1.gnu" type="text/plain">code to produce this figure</a>)
    </p>
</div>
<p>Now we add some lines to the surface and hide parts, which are not visible in 3d.</p>
<pre class="prettyprint">
<span class="k">set</span> <span class="nb">pm3d</span> <span class="nb">depthorder</span> <span class="nb">hidden3d</span> <span class="n">1</span>
<span class="k">set</span> <span class="nb">hidden3d</span>
</pre>
<p>Here the <code>depthorder</code> option takes care of the right positioning of the bottleneck going back into the bottle, which is not correct in Fig. 2. The <code>hidden3d 1</code> option draws lines in the right order for a correctly looking 3d plot using line style 1. The additional <code>set hidden3d</code> command takes care of showing only those lines that are visible in 3d. These options will result in Fig. 3.</p>
<div class="figure">
    <img decoding="async" src="./../../../figs/klein_bottle2.png" alt="Klein bottle" width="350"/></p>
<p class="caption">
        <strong>Fig. 3 </strong>Klein bottle plotted only with pm3d and hidden3d (<a href="./../../../code/klein_bottle2.gnu" type="text/plain">code to produce this figure</a>)
    </p>
</div>
<p>In order to reach at Fig. 1 we just have to set the surface to be transparent, which can be done by the <code>set style fill</code> command.</p>
<pre class="prettyprint">
<span class="k">set</span> <span class="nb">style</span> <span class="nb">fill</span> <span class="nb">transparent</span> <span class="nb">solid</span> <span class="n">0.65</span>
</pre>
]]></content:encoded>
					
					<wfw:commentRss>./../../../klein-bottle/feed/index.html</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
	</channel>
</rss>
