<?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>Gnuplotting</title>
	<atom:link href="http://www.gnuplotting.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gnuplotting.org</link>
	<description>Create scientific plots using Gnuplot</description>
	<lastBuildDate>Tue, 10 Apr 2012 19:28:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Gnuplot 4.6 &#8211; do</title>
		<link>http://www.gnuplotting.org/gnuplot-4-6-do/</link>
		<comments>http://www.gnuplotting.org/gnuplot-4-6-do/#comments</comments>
		<pubDate>Mon, 02 Apr 2012 15:54:14 +0000</pubDate>
		<dc:creator>hagen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[4.6]]></category>
		<category><![CDATA[do]]></category>
		<category><![CDATA[for]]></category>
		<category><![CDATA[iteration]]></category>

		<guid isPermaLink="false">http://www.gnuplotting.org/?p=1324</guid>
		<description><![CDATA[Since last month the new Gnuplot version 4.6 is officially available. There are a lot of interesting changes in this new version and we will cover the bigger ones within the next posts. Here we start with, in my opinion, the nicest new feature: block-structured conditions and loops. Until 4.6 an iteration over different lines [...]]]></description>
			<content:encoded><![CDATA[<p>Since last month the new Gnuplot version 4.6 is officially <a href="http://sourceforge.net/projects/gnuplot/files/gnuplot/4.6.0/">available</a>. There are a lot of interesting <a href="http://gnuplot.info/announce.4.6.0">changes</a> in this new version and we will cover the bigger ones within the next posts. Here we start with, in my opinion, the nicest new feature: <strong>block-structured conditions and loops</strong>.</p>
<p>Until 4.6 an iteration over different lines of code was only possible with the help of an extra file. This technique was used, for example, for the <a href="http://www.gnuplotting.org/animation-gif/">gif animation entry</a>. There the loop was executed by</p>
<pre class="prettyprint">
<span class="v">t</span> = 0
<span class="v">end_time</span> = 1
load 'bessel.plt'
</pre>
<p>with the file <code>bessel.plt</code> containing the code to execute within the loop</p>
<pre class="prettyprint">
# bessel.plt
<span class="v">t</span> = <span class="v">t</span> + 0.02
<span class="v">outfile</span> = <span class="f">sprintf</span>('animation/bessel%03.0f.png',50*<span class="v">t</span>)
set output <span class="v">outfile</span>
splot <span class="v">u</span>*<span class="f">sin</span>(<span class="v">v</span>),<span class="v">u</span>*<span class="f">cos</span>(<span class="v">v</span>),<span class="f">bessel</span>(<span class="v">u</span>,<span class="v">t</span>) w pm3d ls 1
if(<span class="v">t</span>&lt;<span class="v">end_time</span>) reread;
</pre>
<p>This can now be reformulated in a much shorter way by applying the new <code>do</code> command and the block-structure given by the <code>{ }</code></p>
<pre class="prettyprint">
do for [<span class="v">t</span>=0:50] {
    <span class="v">outfile</span> = <span class="f">sprintf</span>('animation/bessel%03.0f.png',<span class="v">t</span>)
    set output <span class="v">outfile</span>
    splot <span class="v">u</span>*<span class="f">sin</span>(<span class="v">v</span>),<span class="v">u</span>*<span class="f">cos</span>(<span class="v">v</span>),<span class="f">bessel</span>(<span class="v">u</span>,<span class="v">t</span>/50.0) w pm3d ls 1
}
</pre>
<p>Now there is no need for an additional file. The only thing to consider is the change of the index <code>t</code>, because for the <code>for</code>-loop <code>t</code> has to be an integer.</p>
<p>The block-structure can in the same way be applied to the <code>if</code>-statement.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gnuplotting.org/gnuplot-4-6-do/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Images within a graph</title>
		<link>http://www.gnuplotting.org/images-within-a-graph/</link>
		<comments>http://www.gnuplotting.org/images-within-a-graph/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 11:37:32 +0000</pubDate>
		<dc:creator>hagen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[arrow]]></category>
		<category><![CDATA[binary]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[iteration]]></category>
		<category><![CDATA[jpg]]></category>
		<category><![CDATA[label]]></category>

		<guid isPermaLink="false">http://www.gnuplotting.org/?p=1382</guid>
		<description><![CDATA[Suppose you have an image and wanted to add some lines, arrows, a scale or whatever to it. Of course you can do this easily with Gnuplot as you can see in Fig. 1. Fig. 1 Plotting a jpg image within your graph and adding a scale (code to produce this figure, image data). Image [...]]]></description>
			<content:encoded><![CDATA[<p>Suppose you have an image and wanted to add some lines, arrows, a scale or whatever to it. Of course you can do this easily with Gnuplot as you can see in Fig. 1.</p>
<div class="figure">
    <img src="http://www.gnuplotting.org/figs/image.png" alt="jpg image"/>
<p class="caption">
        <strong>Fig. 1 </strong>Plotting a jpg image within your graph and adding a scale (<a href="http://www.gnuplotting.org/code/image.gnu" type="text/plain">code to produce this figure</a>, <a href="http://www.gnuplotting.org/data/fish.jpg">image data</a>). Image source: <a href="http://biogeodb.stri.si.edu/sftep/taxon_mod_largepic.php?id=1316">© SFTEP</a>.
    </p>
</div>
<p>To plot the jpg image of the <a href="http://en.wikipedia.org/wiki/Oxycirrhites_typus">longnose hawkfish</a> you have to tell the <code>plot</code> command that you have binary data, the filetype, and choose <code>rgbimage</code> as a plotting style. Also we ensure that the image axes are in the right relation to each other by setting <code>ratio</code> to -1.</p>
<pre class="prettyprint">
set size ratio -1
plot 'fish.jpg' binary filetype=jpg with rgbimage
</pre>
<p>The scale needs a little more work, because Gnuplot can not plot a axis with tics to both directions of it. Hence we are using a bunch of arrows to achieve the same result. The text is than set by labels to the axis.</p>
<pre class="prettyprint">
set arrow from 31,40 to 495,40 nohead front ls 1
set for [<span class="v">ii</span>=0:11] arrow from 31+<span class="v">ii</span>*40,35 to 31+<span class="v">ii</span>*40,45 nohead \
   front ls 1
# set number and unit as different labels in order
# to get a smaller distance between them
set label '0'  at  25,57 front tc ls 1
set label 'cm' at  37,57 front tc ls 1
set label '5'  at 225,57 front tc ls 1
set label 'cm' at 237,57 front tc ls 1
set label '10' at 420,57 front tc ls 1
set label 'cm' at 442,57 front tc ls 1
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gnuplotting.org/images-within-a-graph/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scale paper like grid</title>
		<link>http://www.gnuplotting.org/scale-paper-like-grid/</link>
		<comments>http://www.gnuplotting.org/scale-paper-like-grid/#comments</comments>
		<pubDate>Mon, 05 Mar 2012 16:49:52 +0000</pubDate>
		<dc:creator>hagen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[multiplot]]></category>

		<guid isPermaLink="false">http://www.gnuplotting.org/?p=1370</guid>
		<description><![CDATA[If you want to compare some time series of data with each other it could be a good idea to plot them just onto a grid without anything else. Here we will generate a scale paper like grid and plot two simple functions on it. Fig. 1 Plotting some time data on scale paper like [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to compare some time series of data with each other it could be a good idea to plot them just onto a grid without anything else. Here we will generate a scale paper like grid and plot two simple functions on it.</p>
<div class="figure">
    <img src="http://www.gnuplotting.org/figs/scale_paper_grid.png" alt="colored lines"/>
<p class="caption">
        <strong>Fig. 1 </strong>Plotting some time data on scale paper like grid (<a href="http://www.gnuplotting.org/code/scale_paper_grid.gnu" type="text/plain">code to produce this figure</a>)
    </p>
</div>
<p>In Fig. 1, two harmonic tone complexes are shown, plotted within the <code>multiplot</code> environment. But the thing to consider here is the grid below them. In order to get such a grid, we have to remove all borders and tics. This is done by the following code. </p>
<pre class="prettyprint">
set style line 11 lc rgb '#ffffff' lt 1
set border 0 back ls 11
set tics out nomirror scale 0,0.001
set format ''
</pre>
<p>The second number of <code>scale</code> for the tics corresponds to the minor tics and must be greater than zero, otherwise no minor tics will appear.</p>
<p>In the last step we enable minor tics on both axes, set the style for the grid and define the grid itself.</p>
<pre class="prettyprint">
set mxtics
set mytics
set style line 12 lc rgb '#ddccdd' lt 1 lw 1.5
set style line 13 lc rgb '#ddccdd' lt 1 lw 0.5
set grid xtics mxtics ytics mytics back ls 12 ls 13
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gnuplotting.org/scale-paper-like-grid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple lines with different colors</title>
		<link>http://www.gnuplotting.org/multiple-lines-with-different-colors/</link>
		<comments>http://www.gnuplotting.org/multiple-lines-with-different-colors/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 00:03:50 +0000</pubDate>
		<dc:creator>hagen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[colormap]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[for]]></category>
		<category><![CDATA[label]]></category>
		<category><![CDATA[lines]]></category>
		<category><![CDATA[palette]]></category>

		<guid isPermaLink="false">http://www.gnuplotting.org/?p=1354</guid>
		<description><![CDATA[Most of you will probably know the problem of visualizing more than two dimensions of data. In the past we have seen some solutions to this problem by using color maps, or pseudo 3D plots. Here is another solution which will just plot a bunch of lines, but varying their individual colors. Fig. 1 Plot [...]]]></description>
			<content:encoded><![CDATA[<p>Most of you will probably know the problem of visualizing more than two dimensions of data. In the past we have seen some solutions to this problem by using <a href="http://www.gnuplotting.org/color-maps-and-the-scale-of-axes/">color maps</a>, or <a href="http://www.gnuplotting.org/creating-pseudo-3d-plots/">pseudo 3D plots</a>. Here is another solution which will just plot a bunch of lines, but varying their individual colors.</p>
<div class="figure">
    <img src="http://www.gnuplotting.org/figs/colored_lines1.png" alt="colored lines"/>
<p class="caption">
        <strong>Fig. 1 </strong>Plot of interaural time differences for different frequency channels, indicated by different colors (<a href="http://www.gnuplotting.org/code/colored_lines1.gnu" type="text/plain">code to produce this figure</a>, <a href="http://www.gnuplotting.org/data/ild.txt">data</a>)
    </p>
</div>
<p>For this we first define the colors we want to use. Here we create a transition from blue to green by varying the hue in equal steps. The values can be easily calculated with <a href="http://www.gimp.org">GIMP</a> or any other tool that comes with a color chooser.</p>
<pre class="prettyprint">
set style line 2  lc rgb '#0025ad' lt 1 lw 1.5 # --- blue
set style line 3  lc rgb '#0042ad' lt 1 lw 1.5 #      .
set style line 4  lc rgb '#0060ad' lt 1 lw 1.5 #      .
set style line 5  lc rgb '#007cad' lt 1 lw 1.5 #      .
set style line 6  lc rgb '#0099ad' lt 1 lw 1.5 #      .
set style line 7  lc rgb '#00ada4' lt 1 lw 1.5 #      .
set style line 8  lc rgb '#00ad88' lt 1 lw 1.5 #      .
set style line 9  lc rgb '#00ad6b' lt 1 lw 1.5 #      .
set style line 10 lc rgb '#00ad4e' lt 1 lw 1.5 #      .
set style line 11 lc rgb '#00ad31' lt 1 lw 1.5 #      .
set style line 12 lc rgb '#00ad14' lt 1 lw 1.5 #      .
set style line 13 lc rgb '#09ad00' lt 1 lw 1.5 # --- green
</pre>
<p>Then we plot our data with these colors and get Figure 1 as a result.</p>
<pre class="prettyprint">
plot for [<span class="v">n</span>=2:13] 'itd.txt' u 1:(<span class="f">column</span>(<span class="v">n</span>)*1000) w lines ls <span class="v">n</span>
</pre>
<p>There the <a href="http://en.wikipedia.org/wiki/Interaural_time_difference">interaural time difference (ITD)</a> between the right and left ear for different frequency channels ranging from 236 Hz to 1296 Hz is shown. As can be seen the ITD varies depending on the incident angle (azimuth angle) of the given sound.</p>
<p>Another possibility to indicate the frequency channels given by the different colors is to add a colorbox to the graph as shown in Figure 2.</p>
<div class="figure">
    <img src="http://www.gnuplotting.org/figs/colored_lines2.png" alt="Colored lines"/>
<p class="caption">
        <strong>Fig. 2 </strong>Plot of interaural time differences for different frequency channels, indicated by different colors as shown in the colorbox (<a href="http://www.gnuplotting.org/code/colored_lines2.gnu" type="text/plain">code to produce this figure</a>, <a href="http://www.gnuplotting.org/data/itd.txt">data</a>)
    </p>
</div>
<p>To achieve this we have to set the origin and size of the colorbox ourselves. Note, that the notation is not the same as for a rectangle object and uses only the screen coordinates which is a little bit nasty. In addition we have to define our own color palette, as has been discussed already <a href="http://www.gnuplotting.org/matlab-colorbar-with-gnuplot/">in another colorbox entry</a>. In a last step we add a second phantom plot to our plot command by plotting <code>1/0</code> using the <code>image</code> style in order to get the colorbox drawn onto the graph.</p>
<pre class="prettyprint">
set colorbox user horizontal origin 0.32,0.385 size 0.18,0.035 front
set cbrange [236:1296]
set cbtics ('236 Hz' 236,'1296 Hz' 1296) offset 0,0.5 scale 0
set palette defined (\
    1  '#0025ad', \
    2  '#0042ad', \
    3  '#0060ad', \
    4  '#007cad', \
    5  '#0099ad', \
    6  '#00ada4', \
    7  '#00ad88', \
    8  '#00ad6b', \
    9  '#00ad4e', \
    10 '#00ad31', \
    11 '#00ad14', \
    12 '#09ad00' \
    )
plot for [<span class="v">n</span>=2:13] 'itd.txt' u 1:(<span class="f">column</span>(<span class="v">n</span>)*1000) w lines ls <span class="v">n</span>, \
   1/0 w image
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gnuplotting.org/multiple-lines-with-different-colors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Animation II &#8211; video</title>
		<link>http://www.gnuplotting.org/animation-video/</link>
		<comments>http://www.gnuplotting.org/animation-video/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 13:25:37 +0000</pubDate>
		<dc:creator>hagen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[reread]]></category>
		<category><![CDATA[system]]></category>

		<guid isPermaLink="false">http://www.gnuplotting.org/?p=1189</guid>
		<description><![CDATA[In the first post regarding animations we have created a bunch of png files and combined them to a single gif animation. Now we want to generate again a bunch of png files, but combine them to a movie. Download the video Fig. 1 Video animation of Huygens principle (code to produce this figure, loop [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://www.gnuplotting.org/animation-gif/">first post regarding animations</a> we have created a bunch of png files and combined them to a single gif animation. Now we want to generate again a bunch of png files, but combine them to a movie.</p>
<div class="figure">
  <video id="huygens_principle" controls loop><source src="http://www.gnuplotting.org/video/huygen.webm" type='video/webm; codecs="vorbis,vp8"' /><a href="http://www.gnuplotting.org/video/huygen.webm">Download the video</a></video>
<p class="caption">
  <strong>Fig. 1 </strong>Video animation of Huygens principle (<a href="http://www.gnuplotting.org/code/huygen.gnu" type="text/plain">code to produce this figure</a>, <a href="http://www.gnuplotting.org/code/huygen.plt">loop function</a>)
  </p>
</div>
<p>We create the png files in analogy to the gif example, hence we will discuss only the generation of the movie here. In order to compose a avi file from the png files we are using <a href="http://www.mplayerhq.hu">Mencoder</a>. Gnuplot is able to directly start Mencoder by its <code>system</code> command.</p>
<pre class="prettyprint">
# Create movie with mencoder
<span class="v">ENCODER</span> = system('which mencoder');
if (<span class="f">strlen</span>(<span class="v">ENCODER</span>)==0) print '=== mencoder not found ==='; exit
<span class="v">CMD</span> = 'mencoder mf://animation/*.png -mf fps=25:type=png -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o huygen.avi'
system(<span class="v">CMD</span>)
</pre>
<p>The first two lines check if Mencoder is available and quit gnuplot if not. The Mencoder command itselfs gets the directory containing the png files <code>mf://animation/*.png</code>, frames per second and input type<code>-mf fps=25:type=png</code>, video <code>-ovc</code> and audio <code>-oac</code> options, and finally of course the output file <code>-o huygen.avi</code>.</p>
<p>In order to generate a <a href="http://www.webmproject.org/">webm</a> video file for a web site, ffmpeg can be used to convert the video.</p>
<pre class="prettyprint">
<span class="pr">$</span> ffmpeg -i huygen.avi huygen.webm
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gnuplotting.org/animation-video/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://www.gnuplotting.org/video/huygen.webm" length="192914" type="video/webm" />
		</item>
		<item>
		<title>Adding arrows to the axes</title>
		<link>http://www.gnuplotting.org/adding-arrows-to-the-axes/</link>
		<comments>http://www.gnuplotting.org/adding-arrows-to-the-axes/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 12:47:29 +0000</pubDate>
		<dc:creator>hagen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[arrow]]></category>
		<category><![CDATA[axes]]></category>
		<category><![CDATA[border]]></category>

		<guid isPermaLink="false">http://www.gnuplotting.org/?p=1329</guid>
		<description><![CDATA[Fig. 1 Plot of a sinusoid with arrows on the axes (code to produce this figure, data) You can easily add arrows to the end of the x- and y-axis using the set arrow command. The two last values of the size option determines the opening and closing angles of the arrows. set arrow from [...]]]></description>
			<content:encoded><![CDATA[<div class="figure">
    <img src="http://www.gnuplotting.org/figs/axis_with_arrow.png" alt="Axis with arrow"/>
<p class="caption">
        <strong>Fig. 1 </strong>Plot of a sinusoid with arrows on the axes (<a href="http://www.gnuplotting.org/code/axis_with_arrow.gnu" type="text/plain">code to produce this figure</a>, <a href="http://www.gnuplotting.org/data/battery.dat">data</a>)
    </p>
</div>
<p>You can easily add arrows to the end of the x- and y-axis using the <code>set arrow</code> command. The two last values of the size option determines the opening and closing angles of the arrows. </p>
<pre class="prettyprint">
set arrow from graph 1,0 to graph 1.05,0 size screen 0.025,15,60 \
    filled ls 11
set arrow from graph 0,1 to graph 0,1.05 size screen 0.025,15,60 \
    filled ls 11
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gnuplotting.org/adding-arrows-to-the-axes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Matlab colorbar with Gnuplot</title>
		<link>http://www.gnuplotting.org/matlab-colorbar-with-gnuplot/</link>
		<comments>http://www.gnuplotting.org/matlab-colorbar-with-gnuplot/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 15:03:18 +0000</pubDate>
		<dc:creator>hagen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[colormap]]></category>
		<category><![CDATA[macros]]></category>
		<category><![CDATA[palette]]></category>
		<category><![CDATA[rgb]]></category>

		<guid isPermaLink="false">http://www.gnuplotting.org/?p=1266</guid>
		<description><![CDATA[This time another colormap plot. If you are using Matlab or Octave you are probably be familiar with Matlabs nice default colormap jet. Fig. 1 Photoluminescence yield plotted with the jet colormap from Matlab (code to produce this figure, data) In Fig.1, you see a photoluminescence yield in a given region, and as you can [...]]]></description>
			<content:encoded><![CDATA[<p>This time another <a href="http://www.gnuplotting.org/color-maps-and-the-scale-of-axes/">colormap plot</a>. If you are using Matlab or Octave you are probably be familiar with Matlabs nice default <a href="http://www.mathworks.de/help/techdoc/ref/colormap.html">colormap jet</a>.</p>
<div class="figure">
    <img src="http://www.gnuplotting.org/figs/matlab_colormap.png" alt="Matlab colorbar"/>
<p class="caption">
        <strong>Fig. 1 </strong>Photoluminescence yield plotted with the jet colormap from Matlab (<a href="http://www.gnuplotting.org/code/matlab_colormap.gnu" type="text/plain">code to produce this figure</a>, <a href="http://www.gnuplotting.org/data/matlab_colormap.txt">data</a>)
    </p>
</div>
<p>In Fig.1, you see a photoluminescence yield in a given region, and as you can see Gnuplot is able to apply the jet colormap from Matlab. This can be achieved by defining the palette as follows.</p>
<pre class="prettyprint">
set palette defined ( 0 '#000090',\
                      1 '#000fff',\
                      2 '#0090ff',\
                      3 '#0fffee',\
                      4 '#90ff70',\
                      5 '#ffee00',\
                      6 '#ff7000',\
                      7 '#ee0000',\
                      8 '#7f0000')
</pre>
<p>The numbers <code>0..8</code> are automatically rescaled to <code>0..1</code>, which means you can employ arbitrary numbers here, only their difference counts.</p>
<p>If you want to use this colormap regularly, you can store it in the <a href="http://www.gnuplotting.org/configuration/">Gnuplot config file</a> as a macro.</p>
<pre class="prettyprint">
# ~/.gnuplot
set macros
MATLAB = "defined (0  0.0 0.0 0.5, \
                   1  0.0 0.0 1.0, \
                   2  0.0 0.5 1.0, \
                   3  0.0 1.0 1.0, \
                   4  0.5 1.0 0.5, \
                   5  1.0 1.0 0.0, \
                   6  1.0 0.5 0.0, \
                   7  1.0 0.0 0.0, \
                   8  0.5 0.0 0.0 )"
</pre>
<p>Here we defined the colors directly as rgb values in the range of <code>0..1</code>, which can be alternatively used a color definition.<br />
In order to apply the colormap, we now can simple write</p>
<pre class="prettyprint">
set palette @MATLAB
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gnuplotting.org/matlab-colorbar-with-gnuplot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Equipotential lines</title>
		<link>http://www.gnuplotting.org/equipotential-lines/</link>
		<comments>http://www.gnuplotting.org/equipotential-lines/#comments</comments>
		<pubDate>Sun, 18 Dec 2011 13:02:42 +0000</pubDate>
		<dc:creator>hagen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cntrparam]]></category>
		<category><![CDATA[contour]]></category>
		<category><![CDATA[label]]></category>
		<category><![CDATA[rectangle]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://www.gnuplotting.org/?p=1244</guid>
		<description><![CDATA[In physics equipotential lines describe lines in space which are at the same potential, for example of the electric field. Fig. 1 Equipotential lines of a plate with electric charges (code to produce this figure) In Fig. 1 equipotential lines for the electric field of six charges equally spaced on a plate are shown. In [...]]]></description>
			<content:encoded><![CDATA[<p>In physics <a href="http://en.wikipedia.org/wiki/Equipotential">equipotential lines</a> describe lines in space which are at the same potential, for example of the electric field.</p>
<div class="figure">
    <img src="http://www.gnuplotting.org/figs/equipotential_lines.png" alt="Equipotential lines"/>
<p class="caption">
        <strong>Fig. 1 </strong>Equipotential lines of a plate with electric charges (<a href="http://www.gnuplotting.org/code/equipotential_lines.gnu" type="text/plain">code to produce this figure</a>)
    </p>
</div>
<p>In Fig. 1 equipotential lines for the electric field of six charges equally spaced on a plate are shown. In order to get these lines we need the function of the potential <code>v(x,y)</code> and make a contour plot with <code>splot</code> to a file to save the positions of the lines.</p>
<pre class="prettyprint">
# calculate and save equipotential lines
set view map
unset surface
set contour base
# distance between contour lines according to 1/r
# => equal distance between lines
set cntrparam levels discrete 4,5,6.67,10
set isosam 31,31
set table 'equipotential_lines.txt'
splot <span class="f">v</span>(<span class="v">x</span>,<span class="v">y</span>) w l ls 1
unset table

plot 'equipotential_lines.txt' u 1:2 w l ls 1
</pre>
<p>The positions of the lines are given by the <code>cntrparam levels</code> which are chosen in a way, to get equally spaced lines in the far field. The <code>set table</code> command stores the contour lines to a file, and finally the last command plots the stored lines.</p>
<p>In addition to the equipotential lines the value of the contour is stored as a third column in the <code>equipotential_lines.txt</code> file and can be plotted on the graph, too. This is shown in Fig. 2.</p>
<div class="figure">
    <img src="http://www.gnuplotting.org/figs/equipotential_lines2.png" alt="Equipotential lines with labels"/>
<p class="caption">
        <strong>Fig. 2 </strong>Equipotential lines of a plate with electric charges with labels (<a href="http://www.gnuplotting.org/code/equipotential_lines2.gnu" type="text/plain">code to produce this figure</a>)
    </p>
</div>
<p>To get the label of the contour we have to choose a <code>x</code>-position which is given by <code>lx0</code> in the following. The <code>labels(x,y)</code> function sets a string to the value of the third column, if the right <code>x</code>-position is given and we are above the plate. The function <code>f(x,y)</code> checks if we are near the point where a label should be drawn and undefines the contour line around this point. The size of this area is given by <code>eps</code>.</p>
<pre class="prettyprint">
<span class="v">lx0</span> = 1.14899
<span class="v">eps</span> = 0.15
<span class="f">labels</span>(<span class="v">x</span>,<span class="v">y</span>) = (<span class="v">x</span>==<span class="v">lx0</span> &#038;&#038; <span class="v">y</span>&gt;<span class="v">y0</span>) ? <span class="f">stringcolumn</span>(3) : ""
<span class="f">f</span>(<span class="v">x</span>,<span class="v">y</span>) = (<span class="f">abs</span>(<span class="v">lx0</span>-<span class="v">x</span>)&lt;<span class="v">eps</span> &#038;&#038; <span class="v">y</span>&gt;<span class="v">y0</span>) ? 1/0 : <span class="v">y</span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gnuplotting.org/equipotential-lines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spectrogram</title>
		<link>http://www.gnuplotting.org/spectrogram/</link>
		<comments>http://www.gnuplotting.org/spectrogram/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 17:07:22 +0000</pubDate>
		<dc:creator>hagen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[colormap]]></category>
		<category><![CDATA[for]]></category>
		<category><![CDATA[iteration]]></category>
		<category><![CDATA[label]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[margin]]></category>
		<category><![CDATA[matrix]]></category>
		<category><![CDATA[word]]></category>

		<guid isPermaLink="false">http://www.gnuplotting.org/?p=441</guid>
		<description><![CDATA[A spectrogram is a time-frequency representation that shows how the spectral content of a signal varies with time. In Fig. 1 the spectrogram of the German sentence &#8220;Achte auf die Autos&#8221; is shown. Fig. 1 Spectrogram plotted with plot (code to produce this figure, data) The spectrogram is plotted as mentioned in the color maps [...]]]></description>
			<content:encoded><![CDATA[<p>A spectrogram is a time-frequency representation that shows how the spectral content of a signal varies with time. In Fig. 1 the spectrogram of the German sentence &#8220;Achte auf die Autos&#8221; is shown.</p>
<div class="figure" style="width:420px;">
    <img src="http://www.gnuplotting.org/figs/spec1.png" alt="Spectrogram" width="410"/>
<p class="caption">
        <strong>Fig. 1 </strong>Spectrogram plotted with plot (<a href="http://www.gnuplotting.org/code/spec1.gnu" type="text/plain">code to produce this figure</a>, <a href="http://www.gnuplotting.org/data/spec.dat" type="text/plain">data</a>)
    </p>
</div>
<p>The spectrogram is plotted as mentioned in the <a href="http://www.gnuplotting.org/color-maps-and-the-scale-of-axes/">color maps entry</a>.</p>
<pre class="prettyprint">
plot 'spec.dat' binary matrix with image
</pre>
<p>In addition the letters were putted on the graph at their corresponding time of occurrence. The letters itself and their positions are stored in the two lists <code>syl</code> and <code>xpos</code>. In order to access the single entries of these lists within a for loop the function <code>word</code> is needed.</p>
<pre class="highlight">
<span class="C"># Adding the syllables</span>
<span class="v">syl</span>  <span class="o">=</span> <span class="s">'A    ch   te   a    u    f    d    ie   A    u    t    \
o    s   '</span>
<span class="v">xpos</span> <span class="o">=</span> <span class="s">'0.15 0.22 0.36 0.44 0.49 0.56 0.62 0.66 0.89 1.01 1.16 \
1.26 1.42'</span>
<span class="k">set</span> <span class="k">for</span> [<span class="v">n</span><span class="o">=</span><span class="n">1</span><span class="o">:</span><span class="f">words</span>(<span class="v">syl</span>)] label <span class="f">word</span>(<span class="v">syl</span>,<span class="v">n</span>) at <span class="f">word</span>(<span class="v">xpos</span>,<span class="v">n</span>),<span class="n">6800</span>
</pre>
<p>Another way to plot the spectrogram is by using <code>splot</code> which will result in a different kind of smoothing algorithm of the spectrogram, as can be seen in Fig. 2.</p>
<div class="figure" style="width:420px;">
    <img src="http://www.gnuplotting.org/figs/spec2.png" alt="Spectrogram" width="410"/>
<p class="caption">
        <strong>Fig. 2 </strong>Spectrogram plotted with splot (<a href="http://www.gnuplotting.org/code/spec2.gnu" type="text/plain">code to produce this figure</a>, <a href="http://www.gnuplotting.org/data/spec.dat" type="text/plain">data</a>)
    </p>
</div>
<p>But to get this result we have to fix some of the margins, because <code>plot</code> is two-dimensinal and <code>splot</code> is three-dimensional which is not desired here.</p>
<pre class="highlight">
<span class="k">set</span> border <span class="n">10</span> front ls <span class="n">11</span>
<span class="k">set</span> tmargin at screen <span class="n">0.75</span>
<span class="k">set</span> bmargin at screen <span class="n">0.25</span>
<span class="k">set</span> rmargin at screen <span class="n">0.95</span>
<span class="k">set</span> lmargin at screen <span class="n">0.15</span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gnuplotting.org/spectrogram/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Invert order of entries in the legend</title>
		<link>http://www.gnuplotting.org/invert-legend-entries-order/</link>
		<comments>http://www.gnuplotting.org/invert-legend-entries-order/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 09:10:46 +0000</pubDate>
		<dc:creator>hagen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[invert]]></category>
		<category><![CDATA[key]]></category>
		<category><![CDATA[legend]]></category>

		<guid isPermaLink="false">http://www.gnuplotting.org/?p=1182</guid>
		<description><![CDATA[Sometimes it can be useful to be able to invert the entries of the legend. For example in Fig. 1 we have a plot of two frequency responses with the black one plotted as second one in order to stay in front of the gray one. Fig. 1 Plot of two frequency responses (code to [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes it can be useful to be able to invert the entries of the legend. For example in Fig. 1 we have a plot of two frequency responses with the black one plotted as second one in order to stay in front of the gray one.</p>
<div class="figure">
    <img src="http://www.gnuplotting.org/figs/invert_key1.png" alt="Three points" width="350"/>
<p class="caption">
        <strong>Fig. 1 </strong>Plot of two frequency responses (<a href="http://www.gnuplotting.org/code/invert_key1.gnu" type="text/plain">code to produce this figure</a>, <a href="http://www.gnuplotting.org/data/freq.txt">data</a>)
    </p>
</div>
<p>In order to make the order of the entries in the legend more intuitive we can simple tell Gnuplot to invert them. The result is shown in Fig. 2.</p>
<pre class="prettyprint">
set key invert
</pre>
<div class="figure">
    <img src="http://www.gnuplotting.org/figs/invert_key2.png" alt="Three points" width="350"/>
<p class="caption">
        <strong>Fig. 2 </strong>Plot of two frequency responses (<a href="http://www.gnuplotting.org/code/invert_key2.gnu" type="text/plain">code to produce this figure</a>, <a href="http://www.gnuplotting.org/data/freq.txt">data</a>)
    </p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.gnuplotting.org/invert-legend-entries-order/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

