<?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>svg &#8211; Gnuplotting</title>
	<atom:link href="./index.html?simply_static_page=2082" rel="self" type="application/rss+xml" />
	<link>./../../../index.html</link>
	<description>Create scientific plots using gnuplot</description>
	<lastBuildDate>Mon, 04 Jun 2012 13:18:27 +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>Attractive plots</title>
		<link>./../../../attractive-plots/index.html</link>
					<comments>./../../../attractive-plots/index.html#comments</comments>
		
		<dc:creator><![CDATA[hagen]]></dc:creator>
		<pubDate>Thu, 11 Aug 2011 09:36:19 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[axes]]></category>
		<category><![CDATA[dashed]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[svg]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[tics]]></category>
		<guid isPermaLink="false">./../../../index.html?p=1014</guid>

					<description><![CDATA[As you surely have noticed I don&#8217;t use the default colors and line styles from Gnuplot, but define them myself. The simple reason is that the default colors are not optimized to be very pleasant, but are simply primary colors. I just stumbled over an blog entry of Brighten Godfrey, which deals with some thoughts [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>As you surely have noticed I don&#8217;t use the default colors and line styles from Gnuplot, but define them myself. The simple reason is that the default colors are not optimized to be very pleasant, but are simply primary colors. I just stumbled over an <a href=" http://youinfinitesnake.blogspot.com/2011/02/attractive-scientific-plots-with.html">blog entry of Brighten Godfrey</a>, which deals with some thoughts on beautiful plots.<br />
He suggest to create scientific plots like the way he created his figure which I have reproduced more or less accurate in Fig. 1.</p>
<div class="figure" style="width:420px;">
    <img decoding="async" src="./../../../figs/nice_web_plot.png" alt="nice plot" width="410"/></p>
<p class="caption">
        <strong>Fig. 1 </strong>Nice plot with the pngcairo terminal (<a href="./../../../code/nice_web_plot.gnu" type="text/plain">code to produce this figure</a>, <a href="./../../../data/nice_web_plot.dat" type="text/plain">data</a>)
    </p>
</div>
<p>In Fig. 2 the default output of the <code>pngcairo</code> terminal is shown. I think the difference is quiet obvious.</p>
<div class="figure" style="width:420px;">
    <img decoding="async" src="./../../../figs/not_so_nice_plot.png" alt="not so nice plot" width="410"/></p>
<p class="caption">
        <strong>Fig. 2 </strong>Default output of the pngcairo terminal (<a href="./../../../code/not_so_nice_plot.gnu" type="text/plain">code to produce this figure</a>, <a href="./../../../data/nice_web_plot.dat" type="text/plain">data</a>)
    </p>
</div>
<p>In the following I will have a look at the things we have to do to reach Fig. 1 and why we should do this:</p>
<p>1) change the default colors to more pleasant ones and make the lines a little bit thicker</p>
<pre class="prettyprint">
<span class="k">set</span> style line <span class="n">1</span> lc rgb <span class="s">'#8b1a0e'</span> pt <span class="n">1</span> ps <span class="n">1</span> lt <span class="n">1</span> lw <span class="n">2</span> <span class="C"># --- red</span>
<span class="k">set</span> style line <span class="n">2</span> lc rgb <span class="s">'#5e9c36'</span> pt <span class="n">6</span> ps <span class="n">1</span> lt <span class="n">1</span> lw <span class="n">2</span> <span class="C"># --- green</span>
</pre>
<p>2) put the border more to the background by applying it only on the left and bottom part and put it and the tics in gray</p>
<pre class="prettyprint">
<span class="k">set</span> style line <span class="n">11</span> lc rgb <span class="s">'#808080'</span> lt <span class="n">1</span>
<span class="k">set</span> border <span class="n">3</span> back ls <span class="n">11</span>
<span class="k">set</span> tics nomirror
</pre>
<p>3) add a slight grid to make it easier to follow the exact position of the curves</p>
<pre class="prettyprint">
<span class="k">set</span> style line <span class="n">12</span> lc rgb <span class="s">'#808080'</span> lt <span class="n">0</span> lw <span class="n">1</span>
<span class="k">set</span> grid back ls <span class="n">12</span>
</pre>
<p>The last thing I would like to mention is the problem, that the output of the <code>svg</code> terminal is slightly different from the <code>pngcairo</code> terminal. Especially the dashed line of the grid is not created in the right way,  even though the <code>dashed</code> option is used for the terminal. This and a solution to convert the lines to dashed versions is also mentioned in the <a href="./../../../plotting-the-world/index.html">plotting the world entry</a>. </p>
<div class="figure" style="width:420px;">
    <object data="./../../../figs/nice_web_plot_svg.svg" type="image/svg+xml" style="width:410px; height:250px;"><img decoding="async" src="./../../../figs/nice_web_plot_svg.png" alt="nice plot with svg terminal" width="410"/></object></p>
<p class="caption">
        <strong>Fig. 1 </strong>Nice plot with the svg terminal (<a href="./../../../code/nice_web_plot.gnu" type="text/plain">code to produce this figure</a>, <a href="./../../../data/nice_web_plot.dat" type="text/plain">data</a>)
    </p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>./../../../attractive-plots/feed/index.html</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
		<item>
		<title>Plotting the world</title>
		<link>./../../../plotting-the-world/index.html</link>
					<comments>./../../../plotting-the-world/index.html#comments</comments>
		
		<dc:creator><![CDATA[hagen]]></dc:creator>
		<pubDate>Sun, 11 Jul 2010 11:02:34 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[dashed]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[parametric]]></category>
		<category><![CDATA[svg]]></category>
		<guid isPermaLink="false">http://gnuplot.kkdu.org/?p=186</guid>

					<description><![CDATA[In the Gnuplot demo files folder that comes with your Gnuplot installation exists the file world.dat which contains data in order to plot a map of the world. Therefore we remove the key from the figure and set a grid (the dashed line in Fig. 1). Also we remove the tics by setting the format [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In the Gnuplot demo files folder that comes with your Gnuplot installation exists the file <a href="./../../../data/world.dat">world.dat</a> which contains data in order to plot a map of the world. Therefore we remove the key from the figure and set a grid (the dashed line in Fig. 1). Also we remove the tics by setting the format to nothing and the scale to zero. We could also remove the tics with <code>unset tics</code>, but the grid depends on the tics positions. After that we just plot the data:</p>
<pre class="prettyprint">
<span class="k">unset</span> key
<span class="k">set</span> grid
<span class="k">set</span> format <span class="s">''</span>
<span class="k">set</span> tics scale <span class="n">0</span>
<span class="k">plot</span> <span class="s">'world.dat'</span> with lines linestyle <span class="n">1</span>
</pre>
<div class="figure">
    <object data="./../../../figs/world2d.svg" type="image/svg+xml"><img decoding="async" src="./../../../figs/world2d.png" alt="The world" width="350"/></object></p>
<p class="caption">
        <strong>Fig. 1 </strong>A 2D plot of the world (<a href="./../../../code/world2d.gnu" type="text/plain">code to produce this figure</a>)
    </p>
</div>
<p>Here you can see a problem of the svg terminal of Gnuplot: it can&#8217;t produce dashed lines. In order to fix this, we can use <a href="http://www.inkscape.org/" target="_blank">Inkscape</a> and open the svg file. Then pressing CRTL+F and type gray into the Style field and hit Enter. Now all the grid lines should be selected and you can set their stroke style to dashed by typing CRTL+Shift+F and choose one under Dashes. Doing so will lead to a figure shown in Fig. 2.</p>
<div class="figure">
    <object data="./../../../figs/world2d_inkscape.svg" type="image/svg+xml"><img decoding="async" src="./../../../figs/world2d_inkscape.png" alt="The world" width="350"/></object></p>
<p class="caption">
        <strong>Fig. 2 </strong>The 2D plot of the world edited with Inkscape
    </p>
</div>
<p>We can also easily draw a whole globe in 3D from the given data. Therefore we first add a gray line style, unset the border and arrange the figure margins.</p>
<pre class="prettyprint">
<span class="k">set</span> style line <span class="n">2</span> lc rgb <span
class="s">'#c0c0c0'</span> lt <span class="n">1</span> lw <span class="n">2</span>
<span class="k">unset</span> border
<span class="k">set</span> lmargin screen <span class="n">0</span>
<span class="k">set</span> bmargin screen <span class="n">0</span>
<span class="k">set</span> rmargin screen <span class="n">1</span>
<span class="k">set</span> tmargin screen <span class="n">1</span>
</pre>
<p>The 3D plot needs a little more settings. We have to tell Gnuplot to map the data on a sphere and using angle values in degree. Also we want to have a non transparent world, therefore we need hidden3d. We arrange the appeareance of the plot by setting the xy-plane to the lowest z value in order to avoid an<br />
offset between the lowest z vlaue an the xy-plane. To have Europe in the center we set also the viewport.</p>
<pre class="prettyprint">
<span class="k">set</span> mapping spherical
<span class="k">set</span> angles degrees
<span class="k">set</span> hidden3d
<span class="k">set</span> xyplane at <span class="n">-1</span>
<span class="k">set</span> view <span class="n">56</span>,<span class="n">81</span>
</pre>
<p>For the grid we have to remove the set grid command, because it doesn&#8217;t work with splot. So we draw the grid by our own using the <a href="./../../../understand-parametric-plotting/index.html">parametric mode</a> and finally plot the whole globe:</p>
<pre class="prettyprint">
<span class="k">set</span> parametric
<span class="k">set</span> isosamples <span class="n">25</span>
<span class="k">set</span> urange[<span class="n">0</span>:<span class="n">360</span>]
<span class="k">set</span> vrange[<span class="n">-90</span>:<span class="n">90</span>]
<span class="k">splot</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="f">cos</span>(<span class="v">v</span>)<span
class="o">*</span><span class="f">sin</span>(<span class="v">u</span>),<span
class="f">sin</span>(<span class="v">v</span>) with lines linestyle <span
class="n">2</span>, <span class="ss">\</span>
      <span class="s">'world.dat'</span> with lines linestyle <span
      class="n">1</span>
</pre>
<div class="figure">
    <object data="./../../../figs/world3d.svg" type="image/svg+xml"><img decoding="async" src="./../../../figs/world3d.png" alt="The world" width="350"/></object></p>
<p class="wp-caption-text">
    <strong>Fig. 3 </strong>A 3D plot of the world (<a href="./../../../code/world3d.gnu" type="text/plain">code to produce this figure</a>)
    </p>
</div>
<p>As you can see we have some problems with the data for Africa which lies behind the grid at some points. To avoid this and to make the grid dashed again we draw a grid with tinier radius and use Inkscape.</p>
<pre class="prettyprint">
<span class="c">r</span> <span class="o">=</span> <span class="n">0.99</span>
<span class="k">splot</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">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>) with lines <span class="ss">\</span>
      linestyle <span class="n">2</span>, <span class="ss">\</span>
</pre>
<p>In order to select the grid in Inkscape we have to search after the Style blue for some strange reason (on another PC green was the right color to search). You may have a look at the xml data to figure this out. Therefore under Edit you will find XML Editor. We not only set the stroke style to dashed we also lowered the selected objects<br />
to avoid that any line of the grid covered a black world line. Having done all that we will finally get the nice globe in Fig. 4.</p>
<div class="figure">
    <object data="./../../../figs/world3d_inkscape.svg" type="image/svg+xml"><img decoding="async" src="./../../../figs/world3d_inkscape.png" alt="The world" width="350"/></object></p>
<p class="caption">
    <strong>Fig. 4 </strong>The 3D plot of the world edited with Inkscape
    </p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>./../../../plotting-the-world/feed/index.html</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
	</channel>
</rss>
