K M Masum Habib//masumhabib.com/2014-09-28T10:57:00-07:00Publication Quality Subfigure in Inkscape2014-09-28T10:57:00-07:00K M Masum Habibtag:masumhabib.com,2014-09-28:blog/publication-quality-subfigure-in-inkscape/<p>From Wikipedia, the free encyclopedia:</p>
<blockquote>
Inkscape is a free and open source software vector graphics editor.
Its goal is to implement full support for the Scalable Vector
Graphics (SVG) 1.1 standard. It also supports various other formats
for Import/Export.</blockquote>
<p>Using <a class="reference external" href="/projects/publication-quality-graphs-matlab/">PlotPub</a>, you can create publication quality figures using MATLAB.
However, it does not support sub plots yet. Here, I am going to show you how to
create publication quality subfigures using
<a class="reference external" href="http://www.inkscape.org/">Inkscape</a> and <a class="reference external" href="/projects/publication-quality-graphs-matlab/">PlotPub</a>.</p>
<div class="contents topic" id="contents">
<p class="topic-title first">Contents</p>
<ul class="simple">
<li><a class="reference internal" href="#generating-eps-files-using-plotpub" id="id1">Generating EPS files using PlotPub</a></li>
<li><a class="reference internal" href="#combining-eps-files-using-inkscape" id="id2">Combining EPS files using Inkscape</a><ul>
<li><a class="reference internal" href="#import" id="id3">Import</a></li>
<li><a class="reference internal" href="#annotate" id="id4">Annotate</a></li>
<li><a class="reference internal" href="#export" id="id5">Export</a></li>
<li><a class="reference internal" href="#downloads" id="id6">Downloads</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="generating-eps-files-using-plotpub">
<h2><a class="toc-backref" href="#id1">Generating EPS files using PlotPub</a></h2>
<p>So, finally, you have nailed it. After months (seconds) of
extreme-hard-work (scratching-your-head), you have just got this
state-of-the-art, ground-breaking result. You have shown that
instantaneous power of an induction motor can be expressed as a product
of instantaneous voltage across and instantaneous current through the
motor ;). Now it is time to publish the result and let the world know
who is the boss :D.</p>
<p>So, you grabbed your computer and generated three EPS files (plotV.eps,
plotI.eps and plotP.eps) using PlotPub (download the MATLAB script from
the downloads section):</p>
<div class="figure">
<img alt="" src="//masumhabib.com/blog/publication-quality-subfigure-in-inkscape/images/inkscape_tutorial_plotV.png" />
</div>
<div class="figure">
<img alt="" src="//masumhabib.com/blog/publication-quality-subfigure-in-inkscape/images/inkscape_tutorial_plotI.png" />
</div>
<div class="figure">
<img alt="" src="//masumhabib.com/blog/publication-quality-subfigure-in-inkscape/images/inkscape_tutorial_plotP.png" />
</div>
<p>Now that you have three separate figures, the question is, how to
combine them into one. No worries, Inkscape covers you.</p>
</div>
<div class="section" id="combining-eps-files-using-inkscape">
<h2><a class="toc-backref" href="#id2">Combining EPS files using Inkscape</a></h2>
<p><a class="reference external" href="http://www.inkscape.org/en/download/">Download</a> and install Inkscape
on your computer. The installation should be easy. But if you need,
<a class="reference external" href="http://wiki.inkscape.org/wiki/index.php/Installing_Inkscape">help</a>
is closer than you think.</p>
<div class="section" id="import">
<h3><a class="toc-backref" href="#id3">Import</a></h3>
<p>To start, open Inkscape and click the <strong>File > Import</strong> menu. A dialog
box will appear. Browse your file system to select the voltage figure
(plotV.eps) file and click <strong>Open</strong>. Make sure the import settings look
like the following.</p>
<div class="figure">
<img alt="" src="//masumhabib.com/blog/publication-quality-subfigure-in-inkscape/images/inkscape_tutorial_import_settings.png" />
</div>
<p>Click <strong>OK</strong> to complete the import. If your figure looks too small, you
can change the zoom level from the bottom-right of your Inkscape window:</p>
<div class="figure">
<img alt="" src="//masumhabib.com/blog/publication-quality-subfigure-in-inkscape/images/inkscape_tutorial_zoom.png" />
</div>
<p>Similarly, import plotI.eps and plotP.eps.</p>
</div>
<div class="section" id="annotate">
<h3><a class="toc-backref" href="#id4">Annotate</a></h3>
<p>Choose the <strong>Select and transform object</strong> tool from the left toolbar:</p>
<div class="figure">
<img alt="" src="//masumhabib.com/blog/publication-quality-subfigure-in-inkscape/images/inkscape_tutorial_select_tool.png" />
</div>
<p>and select any one of the figures. Now you should
be able to move the figure by dragging-and-dropping or by pressing the
arrow keys. Now move the figures to arrange them one beneath the other.
To align the figures, select them all then click <strong>Object > Align and
Distribute</strong> menu. Now select <strong>Align right sides</strong> from the toolbox on
the right hand side:</p>
<div class="figure">
<img alt="" src="//masumhabib.com/blog/publication-quality-subfigure-in-inkscape/images/inkscape_tutorial_align_right.png" />
</div>
<p>Now let's add labels to the figure. To add text, select <strong>Create text
and edit objects</strong> from the left toolbox:</p>
<div class="figure align-center">
<img alt="" src="//masumhabib.com/blog/publication-quality-subfigure-in-inkscape/images/inkscape_tutorial_edit_text.png" />
</div>
<p>and click on the voltage plot and type <strong>(a)</strong>. Now increase the font
size from the toolbox:</p>
<div class="figure">
<img alt="" src="//masumhabib.com/blog/publication-quality-subfigure-in-inkscape/images/inkscape_tutorial_font.png" />
</div>
<p>Similarly create <strong>(b)</strong> and
<strong>(c)</strong> labels and put them on current and power plots. When you are
done, your figure should look like the following.</p>
<div class="figure">
<img alt="" src="//masumhabib.com/blog/publication-quality-subfigure-in-inkscape/images/inkscape_tutorial_combined1.png" />
</div>
<p>At this stage, it is a good idea to save your work. Click <strong>File >
Save</strong>, provide a file name, choose <strong>Inkscape SVG (*.svg)</strong> as file
type and click <strong>Save</strong>.</p>
</div>
<div class="section" id="export">
<h3><a class="toc-backref" href="#id5">Export</a></h3>
<p>To export your figure as an EPS file, select <strong>File > Save a Copy</strong>
menu. Make sure you select <strong>Encapsulated PostScript (*.eps)</strong> as the
file type and click <strong>Save</strong>. <strong>Encapsulated PostScript</strong> dialog box
will appear. Make sure your options look like:</p>
<div class="figure">
<img alt="" src="//masumhabib.com/blog/publication-quality-subfigure-in-inkscape/images/inkscape_tutorial_EPS_options.png" />
</div>
<p>and click OK. This will create and EPS file containing three figures
combined. Easy, right?</p>
<p>To export a PNG file, click <strong>File > Export Bitmap</strong> menu, the <strong>Export
Bitmap</strong> dialog will appear. Select <strong>Drawing</strong> tab from the <strong>Export
Area</strong>, enter 600 as <strong>dpi</strong> and choose a proper file name and location,
and hit <strong>Export</strong>. A PNG image will be created.</p>
</div>
<div class="section" id="downloads">
<h3><a class="toc-backref" href="#id6">Downloads</a></h3>
<p>The download package contains the MATLAB script, the EPS files and the
SVG files.</p>
<ul class="simple">
<li><a class="reference external" href="//masumhabib.com/blog/publication-quality-subfigure-in-inkscape/source/inkscape_tutorial_source.zip">Source files</a>.</li>
</ul>
<p>Inkscape is a very powerful tool that can be used to modify anything and
everything of your figure. To do that, you first need to ungroup the
figure. Select the figure you want to modify and then press Ctrl+Shift+G
multiple times to ungroup everything. Now you should be able to
add/edit/move any object in the figure. Click ... no, wait, that is
enough for today.</p>
<p>Good luck with your Nobel prize though :-D.</p>
<p><strong>Last update: 12:18 PM, September 28, 2014.</strong></p>
</div>
</div>
How to Install the Boost Library with MPI and without Root Access2014-03-04T11:54:00-08:00K M Masum Habibtag:masumhabib.com,2014-03-04:blog/how-to-install-the-boost-library-with-mpi-and-without-root-access/<p><strong>UPDATE-1:</strong> For Boost v1.56.0,
<tt class="docutils literal"><span class="pre">boost_1_56_0/tools/build/v2/user-config.jam</span></tt> is not used by the build
system, use <tt class="docutils literal"><span class="pre">boost_1_56_0/project-config.jam</span></tt> instead.</p>
<p>Boost is huge collection of C++ libraries. It is complementary to the
standard C++ library. Like all other libraries, you'll need root access
to install the Boost library on Unix and Unix like systems. If you are
not the system admin, you can compile and install it in your home
folder. In this tutorial I'll show how to compile and install Boost in
your home directory without root access.</p>
<p>Boost library has a C++ wrapper (<tt class="docutils literal"><span class="pre">boost::mpi</span></tt>) for lower level MPI
routines. By default, the MPI libraries are not enabled in boost. In
this tutorial, we will discuss how to enable and compile <tt class="docutils literal"><span class="pre">boost::mpi</span></tt>
or any other libraries that needs compilation.</p>
<p>In this tutorial I assume that you are familiar with command line and
GNU/Linux. The following procedure should be similar in other Unix like
operating systems.</p>
<p>Download the latest version of boost source code from
<a class="reference external" href="http://www.boost.org/users/download/">here</a>, put it under
<tt class="docutils literal">/home/username/src</tt> folder and untar the archive.</p>
<div class="highlight"><pre><span></span><span class="nb">cd</span> ~/src
tar -xvf boost_1_55_0.tar.gz
</pre></div>
<p>A new folder named <tt class="docutils literal">boost_1_55_0</tt> will be created. To configure
boost for your host/cluster, change directory to <tt class="docutils literal">boost_1_55_0</tt> and
use <tt class="docutils literal">bootstrap.sh</tt> command.</p>
<div class="highlight"><pre><span></span><span class="nb">cd</span> boost_1_55_0
./bootstrap.sh --help
./bootstrap.sh --show-libraries
</pre></div>
<p>Here, the <tt class="docutils literal">./bootstrap.sh <span class="pre">--help</span></tt> command will show you a help
message and <tt class="docutils literal">./bootstrap.sh <span class="pre">--show-libraries</span></tt> all available
libraries you need to compile.</p>
<p>In order to install Boost in your home directory, use <tt class="docutils literal"><span class="pre">--prefix</span></tt>
option for <tt class="docutils literal">bootstrap.sh</tt>. You can enable or disable libraries using
<tt class="docutils literal"><span class="pre">--with-libraries</span></tt> or <tt class="docutils literal"><span class="pre">--without-libraries</span></tt> options, respectively.</p>
<p>To build Boost with MPI, use:</p>
<div class="highlight"><pre><span></span>./bootstrap.sh --prefix<span class="o">=</span>/home/username/usr --with-libraries<span class="o">=</span>mpi
</pre></div>
<p>If you want to build everything issue the following command:</p>
<div class="highlight"><pre><span></span>./bootstrap.sh --prefix<span class="o">=</span>/home/username/usr --without-libraries<span class="o">=</span>
</pre></div>
<p>To compile <tt class="docutils literal"><span class="pre">boost::mpi</span></tt>, we need to find out the MPI wrapper for C++
compiler (<tt class="docutils literal">mpic++</tt>). The <tt class="docutils literal">mpic++</tt> script comes with MPICH2 (and
probably with OpenMPI) library. To find the path of <tt class="docutils literal">mpic++</tt>, issue
the following command:</p>
<div class="highlight"><pre><span></span>$ which mpic++
</pre></div>
<p>In standard GNU/Linux installations, <tt class="docutils literal">mpic++</tt> is located at either
<tt class="docutils literal">/usr/local/bin</tt> or <tt class="docutils literal">/usr/bin</tt>. To build MPI add full path to
<tt class="docutils literal">mpic++</tt> or just <tt class="docutils literal">mpic++</tt> at the end of
<tt class="docutils literal"><span class="pre">boost_1_55_0/tools/build/v2/user-config.jam</span></tt> file:</p>
<div class="highlight"><pre><span></span><span class="c1"># MPI</span>
using mpi : /usr/bin/mpic++ <span class="p">;</span>
</pre></div>
<p>or,</p>
<div class="highlight"><pre><span></span><span class="c1"># MPI</span>
using mpi : mpic++ <span class="p">;</span>
</pre></div>
<p>Configuration is done, let's make and install it:</p>
<div class="highlight"><pre><span></span>./b2 install <span class="p">|</span> tee install.log
</pre></div>
<p>the log will be saved in install.log file so that you can go back andcheck if something goes wrong.</p>
<p>Boost libraries will be installed in <tt class="docutils literal">/home/username/usr/lib</tt> and the
header files will be installed in <tt class="docutils literal">/home/username/usr/include/boost</tt>
folder.</p>
<p>Include boost in your program using:</p>
<div class="highlight"><pre><span></span><span class="c1">#include <boost/mpi.hpp></span>
<span class="c1">#include <boost/serialization/string.hpp></span>
<span class="c1">#include <boost/serialization/access.hpp></span>
<span class="c1">#include <boost/serialization/split_free.hpp></span>
namespace <span class="nv">mpi</span> <span class="o">=</span> boost::mpi<span class="p">;</span>
</pre></div>
<p>etc. To compile your program, you will need to add
<tt class="docutils literal"><span class="pre">-I/home/username/usr/include</span></tt> option while invoking the compiler.</p>