<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Homepage of Michael Goerz - tikz</title>
 <link href="http://users.physik.fu-berlin.de/~mgoerz/feeds/tags/tikz" rel="self"/>
 <link href="http://users.physik.fu-berlin.de/~mgoerz/"/>
 <updated>2013-03-14T16:35:44+01:00</updated>
 <author>
   <name>Michael Goerz</name>
   <email>goerz@physik.fu-berlin.de</email>
 </author>

 
 <entry>
   <title>Creating Combined tikz/png Plots</title>
   <link href="blog/2010/01/creating-combined-tikzpng-plots/"/>
   <updated>2010-01-24T00:00:00+01:00</updated>
   <id>blog/2010/01/creating-combined-tikzpng-plots</id>
   <content type="html">&lt;p&gt;In order to create truly high quality plots, you can have gnuplot write tikz files. Wheres the latest CVS development version of gnuplot have the tikz terminal included, I&amp;#8217;m still using the &lt;a href=&#39;http://peter.affenbande.org/gnuplot/&#39;&gt;patch by Peter Hedwig for gnuplot 4.2&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Generating tikz code from gnuplot works very nicely for &amp;#8220;standard&amp;#8221; plots, but can be problematic for others. If the plot contains a lot of points, the resulting tikz file can be hundreds of megabyte in side, and the resulting pdf will constipate your pdf reader, if you get it to compile at all. In fact, you run into the same problem if you use the pdf or postscript terminal in gnuplot directly.&lt;/p&gt;

&lt;p&gt;Another type of plot where this tends to happen is &lt;a href=&#39;http://t16web.lanl.gov/Kawano/gnuplot/plotpm3d-e.html&#39;&gt;3D color maps&lt;/a&gt;. The result in tikz is thousands of small colored squares, each of to be rendered as vector graphics.&lt;/p&gt;

&lt;p&gt;Is there any way to make these plots manageable, while keeping the high quality of tikz output in place? A possible solution is to combine a bitmapped plot with vector-graphics decorations (axes, legend, etc.). To do this, we let gnuplot generate the same plot twice: once with the tikz terminal, and once with the png terminal, but without any axes, labels, etc. We then modify the tikz output and delete all the parts for the actual plot, and insert the png image in their place. This means we have the png image, and everything else drawn on top of it with tikz.&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s look at this in practice.&lt;/p&gt;

&lt;p&gt;Suppose I have a &lt;a href=&#39;wig.bz2&#39;&gt;huge data file&lt;/a&gt; of a &lt;a href=&#39;http://en.wikipedia.org/wiki/Wigner_quasi-probability_distribution&#39;&gt;Wigner plot&lt;/a&gt; that I want to visualize as a color map. I use the following gnuplot file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;set term lua plotsize 8cm,6cm font &amp;quot; \\tiny &amp;quot;
set out &amp;quot;wigner.tikz&amp;quot;

set pm3d map
set palette defined (-0.0015 &amp;quot;blue&amp;quot;, 0 &amp;quot;white&amp;quot;, 0.0015 &amp;quot;red&amp;quot;)

splot &amp;quot;wig&amp;quot; u 1:2:3

set term png size 800,600
set out &amp;quot;wigner.png&amp;quot;

set lmargin at screen 0
set rmargin at screen 1.0
set bmargin at screen 0
set tmargin at screen 1.0

unset tics
unset border

splot &amp;quot;wig&amp;quot; u 1:2:3&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We can see that the tikz plot is create first, then the png plot. With those settings, the png file contains just the actual plot area without any margins whatsoever. It looks like this: &lt;a href=&#39;wigner.png&#39;&gt;wigner.png&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The tikz file that comes out of this has some 150 MB. However, if we open it up in a text editor, we can easily identify its structure, and write a small script that replaces the actual plot with the png file:&lt;/p&gt;

&lt;p&gt;&lt;a href=&#39;combine_pm3dmap.pl&#39;&gt;combine_pm3dmap.pl&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The second thing this script does is to make the plot legend look quite a bit nicer. In the original, the legend was just a bunch of colored boxes stacked on top of each other to create a fake gradient, which looks horrible. We replace this with two true gradients, which works because we set the colors in the gnuplot script to go from blue to white to red. So we can have one true gradient from blue to white, and one from white to red.&lt;/p&gt;

&lt;p&gt;Of course, the script is not really general, but I think it should work for any pm3d map plot that uses a three-color gradient centered around white as the palette. Also, if it&amp;#8217;s just for a single plot, you could just as easily do this by hand.&lt;/p&gt;

&lt;p&gt;After processing the tikz file by calling &lt;code&gt;./combine_pm3dmap.pl wigner.tikz
wigner.png&lt;/code&gt;, we get this modified tikz file that is only 4.8 KB in size:&lt;/p&gt;

&lt;p&gt;&lt;a href=&#39;wigner.tikz&#39;&gt;wigner.tikz&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It can be easily compiled (e.g with the &lt;a href=&#39;http://kogs-www.informatik.uni-hamburg.de/~meine/tikz/process/#tikz2pdf&#39;&gt;tikz2pdf&lt;/a&gt; script, and don&amp;#8217;t forget to include &lt;a href=&#39;http://peter.affenbande.org/gnuplot/&#39;&gt;gnuplot-lua-tikz.sty&lt;/a&gt;), resulting in the following pdf:&lt;/p&gt;

&lt;p&gt;&lt;a href=&#39;wigner.pdf&#39;&gt;wigner.pdf&lt;/a&gt;&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>OCT Diagrams in TikZ</title>
   <link href="blog/2009/07/oct-diagrams-in-tikz/"/>
   <updated>2009-07-26T00:00:00+02:00</updated>
   <id>blog/2009/07/oct-diagrams-in-tikz</id>
   <content type="html">&lt;p&gt;I decided to make my first really complex TikZ drawing: A diagram explaining the implementation of an Optimal Control Theory algorithm I did recently. There is a print version:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&#39;oct_diagram.pdf&#39;&gt;oct_diagram.pdf&lt;/a&gt; (&lt;a href=&#39;oct_diagram.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;

&lt;li&gt;&lt;a href=&#39;oct_diagram.tikz&#39;&gt;oct_diagram.tikz&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In addition to that, there are some animated presentation slides, explaining three variations of the algorithm:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&#39;oct_slides.pdf&#39;&gt;oct_slides.pdf&lt;/a&gt; (&lt;a href=&#39;oct_slides.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;

&lt;li&gt;&lt;a href=&#39;oct_storeall.tikz&#39;&gt;oct_storeall.tikz&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href=&#39;oct_storenone.tikz&#39;&gt;oct_storenone.tikz&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href=&#39;oct_segments.tikz&#39;&gt;oct_segments.tikz&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The process of creating these diagrams was fairly involved, but not more than I would have expected. I don&amp;#8217;t think any other tool would have been up to the task, and the result is quite exhilarating. The principles of TeX/TikZ make it quite easy to create variations of existing pictures.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Printable Paper with LaTeX and TikZ</title>
   <link href="blog/2009/07/printable-paper-with-latex-and-tikz/"/>
   <updated>2009-07-17T00:00:00+02:00</updated>
   <id>blog/2009/07/printable-paper-with-latex-and-tikz</id>
   <content type="html">&lt;p&gt;A little while ago, I played around with &lt;a href=&#39;http://www.texample.net/tikz/&#39;&gt;TikZ&lt;/a&gt; to make printable paper. As it turns out, this is absolutely trivial, and with just a few lines you can generate pretty much anything you can imagine. Here are the examples that I generated:&lt;/p&gt;

&lt;h4 id=&#39;a4_paper&#39;&gt;A4 paper&lt;/h4&gt;

&lt;h5 id=&#39;blank_paper&#39;&gt;Blank Paper&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&#39;a4_lin24_blank.pdf&#39;&gt;Lin 24 blank page with right margin&lt;/a&gt; (&lt;a href=&#39;a4_lin24_blank.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h5 id=&#39;ruled_paper&#39;&gt;Ruled Paper&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&#39;a4_lin25_lined.pdf&#39;&gt;Lin 25 9mm rules with right margin&lt;/a&gt; (&lt;a href=&#39;a4_lin25_lined.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;

&lt;li&gt;&lt;a href=&#39;a4_lin27_lined.pdf&#39;&gt;Lin 27 9mm rules with two margins&lt;/a&gt; (&lt;a href=&#39;a4_lin27_lined.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h5 id=&#39;graph_paper&#39;&gt;Graph Paper&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&#39;a4_lin22_squared.pdf&#39;&gt;Lin 22 5mm graph paper, no margins&lt;/a&gt; (&lt;a href=&#39;a4_lin22_squared.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;

&lt;li&gt;&lt;a href=&#39;a4_lin23_rect5x9.pdf&#39;&gt;Lin 23 5x9mm graph paper, no margins&lt;/a&gt; (&lt;a href=&#39;a4_lin23_rect5x9.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;

&lt;li&gt;&lt;a href=&#39;a4_lin26_squared.pdf&#39;&gt;Lin 26 5mm graph paper with right margin&lt;/a&gt; (&lt;a href=&#39;a4_lin26_squared.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;

&lt;li&gt;&lt;a href=&#39;a4_lin28_squared.pdf&#39;&gt;Lin 28 5mm graph paper with two margins&lt;/a&gt; (&lt;a href=&#39;a4_lin28_squared.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;

&lt;li&gt;&lt;a href=&#39;a4_millimeter.pdf&#39;&gt;Millimeter graph paper&lt;/a&gt; (&lt;a href=&#39;a4_millimeter.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h5 id=&#39;underlay_paper&#39;&gt;Underlay Paper&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&#39;a4_lin22_squared_master.pdf&#39;&gt;Lin 22 5mm underlay, no margins&lt;/a&gt; (&lt;a href=&#39;a4_lin22_squared_master.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;

&lt;li&gt;&lt;a href=&#39;a4_lin28_squared_master.pdf&#39;&gt;Lin 28 5mm underlay with two margins&lt;/a&gt; (&lt;a href=&#39;a4_lin28_squared_master.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;

&lt;li&gt;&lt;a href=&#39;a4_personal_master.pdf&#39;&gt;Personal Correspondence&lt;/a&gt; (&lt;a href=&#39;a4_personal_master.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&#39;letter_size_paper&#39;&gt;Letter size paper&lt;/h4&gt;

&lt;h5 id=&#39;cornell_paper&#39;&gt;Cornell Paper&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&#39;letter_cornell_blank.pdf&#39;&gt;Cornell blank note taking paper&lt;/a&gt; (&lt;a href=&#39;letter_cornell_blank.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;

&lt;li&gt;&lt;a href=&#39;letter_cornell_ruled.pdf&#39;&gt;Cornell college ruled note taking paper&lt;/a&gt; (&lt;a href=&#39;letter_cornell_ruled.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;

&lt;li&gt;&lt;a href=&#39;letter_cornell_graph.pdf&#39;&gt;Cornell ¼ inch graph note taking paper&lt;/a&gt; (&lt;a href=&#39;letter_cornell_graph.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h5 id=&#39;ruled_paper&#39;&gt;Ruled Paper&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&#39;letter_narrow_ruled.pdf&#39;&gt;Narrow ruled paper&lt;/a&gt; (&lt;a href=&#39;letter_narrow_ruled.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;

&lt;li&gt;&lt;a href=&#39;letter_college_ruled.pdf&#39;&gt;College ruled paper&lt;/a&gt; (&lt;a href=&#39;letter_college_ruled.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;

&lt;li&gt;&lt;a href=&#39;letter_wide_ruled.pdf&#39;&gt;Wide ruled paper&lt;/a&gt; (&lt;a href=&#39;letter_wide_ruled.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h5 id=&#39;graph_paper&#39;&gt;Graph Paper&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&#39;letter_inch4squared.pdf&#39;&gt;¼ inch graph paper with two margins&lt;/a&gt; (&lt;a href=&#39;letter_inch4squared.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;

&lt;li&gt;&lt;a href=&#39;letter_millimeter.pdf&#39;&gt;Millimeter graph paper&lt;/a&gt; (&lt;a href=&#39;letter_millimeter.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h5 id=&#39;underlay_paper&#39;&gt;Underlay Paper&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&#39;letter_inch4squared_master.pdf&#39;&gt;¼ inch graph underlay with two margins&lt;/a&gt; (&lt;a href=&#39;letter_inch4squared_master.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;

&lt;li&gt;&lt;a href=&#39;letter_personal_master.pdf&#39;&gt;Personal Correspondence&lt;/a&gt; (&lt;a href=&#39;letter_personal_master.tex&#39;&gt;TeX&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can adapt any of these examples to your needs easily, as well as create more complicated layouts. Anything you can find on &lt;a href=&#39;http://www.printablepaper.net/&#39;&gt;http://www.printablepaper.net/&lt;/a&gt;, for sure. To compile, run the tex file through pdflatex twice.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Poster for DPG Conference</title>
   <link href="blog/2009/03/poster-for-dpg-conference/"/>
   <updated>2009-03-30T00:00:00+02:00</updated>
   <id>blog/2009/03/poster-for-dpg-conference</id>
   <content type="html">&lt;p&gt;This is the poster I did for the &lt;a href=&#39;http://www.dpg-physik.de/index.html&#39;&gt;DPG&lt;/a&gt; &lt;a href=&#39;http://hamburg09.dpg-tagungen.de/index.html&#39;&gt;Spring Conference&lt;/a&gt; that took place in Hamburg the first week of march.&lt;/p&gt;

&lt;p&gt;&lt;a href=&#39;dpg_poster.pdf&#39;&gt;dpg_poster.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Doing it in LaTeX was quite a nice experience. I used the &lt;a href=&#39;http://www.ctan.org/tex-archive/help/Catalogue/entries/a0poster.html&#39;&gt;a0poster&lt;/a&gt; package. Most of the figures are done in &lt;a href=&#39;http://www.texample.net/tikz/&#39;&gt;TikZ&lt;/a&gt;. This includes the plots: there is a very nice &lt;a href=&#39;http://peter.affenbande.org/gnuplot/&#39;&gt;TikZ-Terminal&lt;/a&gt; for &lt;a href=&#39;http://www.gnuplot.info/&#39;&gt;gnuplot&lt;/a&gt;. You have to recompile your own gnuplot in order to use that terminal, but that wasn&amp;#8217;t so hard. The gate diagram was done using &lt;a href=&#39;http://www.media.mit.edu/quanta/qasm2circ/&#39;&gt;quasm&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here is the complete source for the poster, without the data for the pulses:&lt;/p&gt;

&lt;p&gt;&lt;a href=&#39;poster.zip&#39;&gt;poster.zip&lt;/a&gt;&lt;/p&gt;</content>
 </entry>
 
 
</feed>