<?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>pm3d &#8211; Gnuplotting</title>
	<atom:link href="./index.html?simply_static_page=2022" 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>Heat maps</title>
		<link>./../../../heat-maps/index.html</link>
					<comments>./../../../heat-maps/index.html#comments</comments>
		
		<dc:creator><![CDATA[hagen]]></dc:creator>
		<pubDate>Fri, 29 Jul 2011 21:57:07 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[hidden3d]]></category>
		<category><![CDATA[parametric]]></category>
		<category><![CDATA[pm3d]]></category>
		<category><![CDATA[sphere]]></category>
		<guid isPermaLink="false">./../../../index.html?p=980</guid>

					<description><![CDATA[In one post we have used the parametric plot option to plot the world. Here we want to add some temperature data as a heat map to the world plots. The data show the temperature anomalies of the year 2005 in comparison to the baseline 1951-1980 and is part of the GISTEMP data set. Fig. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In one post we have used the parametric plot option to <a href="./../../../plotting-the-world/index.html">plot the world</a>. Here we want to add some temperature data as a heat map to the world plots. The data show the temperature anomalies of the year 2005 in comparison to the baseline 1951-1980 and is part of the <a href="http://data.giss.nasa.gov/gistemp/" target="_blank">GISTEMP</a> data set.</p>
<div class="figure">
    <img decoding="async" src="./../../../figs/heatmap2d.png" alt="Heat map" width="350"/></p>
<p class="caption">
        <strong>Fig. 1 </strong>A 2D heat map of the temperature anomalies in 2005 to the baseline 1951-1980 (<a href="./../../../code/heatmap2d.gnu" type="text/plain">code to produce this figure</a>, <a href="./../../../data/temperature.dat">temperature data</a>, <a href="./../../../data/world.dat">world data</a>)
    </p>
</div>
<p>The first problem you face, if you want to create a heat map, is that the data has to be in a specific format shown in the <a href="http://gnuplot.sourceforge.net/demo/heatmaps.html">Gnuplot example page for heat maps</a>. Therefore we first arrange the data and end up with this <a href="./../../../data/temperature.dat">temperature anomalies file</a>. Unknown data points are given by 9999.0.</p>
<p>In order to plot this data to the 2D world map we have to add a reasonable <code>cbrange</code> and a color <code>palette</code> and the plot command for the map:</p>
<pre class="prettyprint">
<span class="k">set</span> cbrange [<span class="n">-5</span>:<span class="n">10</span>]
<span class="k">set</span> palette defined (<span class="n">0</span> <span class="s">"blue"</span>,<span class="n">17</span> <span class="s">"#00ffff"</span>,<span class="n">33</span> <span class="s">"white"</span>,<span class="n">50</span> <span class="s">"yellow"</span>,\
    <span class="n">66</span> <span class="s">"red"</span>,<span class="n">100</span> <span class="s">"#990000"</span>,<span class="n">101</span> <span class="s">"grey"</span>)
<span class="k">plot</span> <span class="s">'temperature.dat'</span> u <span class="n">2</span>:<span class="n">1</span>:<span class="n">3</span> w image, \
     <span class="s">'world.dat'</span> with lines linestyle <span class="n">1</span>
</pre>
<p>The trick with the wide range from 0 to 101 for the color bar is chosen in order to use <code>grey</code> for the undefined values (9999.0) without seeing the grey color in the color bar. The result is shown in Fig. 1.</p>
<div class="figure">
    <img decoding="async" src="./../../../figs/heatmap3d.png" alt="Heat map" width="350"/></p>
<p class="caption">
        <strong>Fig. 2 </strong>A 3D heat map of the temperature anomalies in 2005 to the baseline 1951-1980 (<a href="./../../../code/heatmap3d.gnu" type="text/plain">code to produce this figure</a>, <a href="./../../../data/temperature.dat">temperature data</a>, <a href="./../../../data/world.dat">world data</a>)
    </p>
</div>
<p>The same data can easily be applied to the 3D plot of the world. We have to add <code>front</code> to the <code>hidden3d</code> command in order to make the black world lines visible. In addition the radius must be given explicitly as third column to the plot command for the temperature data.</p>
<pre class="prettyprint">
<span class="k">set</span> hidden3d front
<span class="k">splot</span> <span class="s">'temperature.dat'</span> u <span class="n">2</span>:<span class="n">1</span>:(<span class="n">1</span>):<span class="n">3</span> w pm3d, \
      <span class="c">r</span><span class="o">*</span><span class="f">cos</span>(<span
class="v">v</span>)<span class="o">*</span><span class="f">cos</span>(<span
class="v">u</span>),<span class="c">r</span><span class="o">*</span><span class="f">cos</span>(<span class="v">v</span>)<span class="o">*</span><span class="f">sin</span>(<span class="v">u</span>),<span class="c">r</span><span class="o">*</span><span class="f">sin</span>(<span class="v">v</span>) w l ls <span class="n">2</span>, \
      <span class="s">'world.dat'</span> u <span class="n">1</span>:<span class="n">2</span>:(<span class="n">1</span>) w l ls <span class="n">1</span>
</pre>
<p>The result is shown in Fig. 2.</p>
]]></content:encoded>
					
					<wfw:commentRss>./../../../heat-maps/feed/index.html</wfw:commentRss>
			<slash:comments>5</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>
