TeXblog

 Typography with TeX and LaTeX

Archive for the 'Graphics' Category

Happy New Year!

Januar 1st, 2013 by Stefan Kottwitz

Happy New Year for all!

Fireworks

The animated GIF image shows fireworks displayed with TikZ written by Chris Hughes aka cmhughes on TeX.SE. Follow the link to see further fireworks effects.

The code is:

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing,decorations.shapes}
 
\begin{document}
 
\foreach \radius in {1,2,...,20}
{
\begin{tikzpicture}
  % background rectangle
  \filldraw[black] (-3,-3) rectangle (5,3);
  % skyline
  \filldraw[black!80!blue](-3,-3)--(-3,-2)--(-2.5,-2)--(-2.5,-1)--(-2.25,-1)--(-2.25,-2)--(-2,-2)
                            --(-2,-1)--(-1.75,-0.75)--(-1.5,-1)
                            --(-1.5,-2)--(-1.1,-2)--(-1.1,0)--(-0.5,0)--(-0.5,-2)
                            --(0,-2)--(0,-1.5)--(1,-1.5)--(1.25,-0.5)--(1.5,-1.5)--(1.5,-2)
                            --(2,-2)--(2,0)--(2.5,0)--(2.5,-2)
                            --(3,-2)--(3,-1)--(4,-1)--(4,-2)--(5,-2)--(5,-3)--cycle;
  % moon- what a hack!
  \filldraw[white] (4,2.5) arc (90:-90:20pt);
  \filldraw[black] (3.8,2.5) arc (90:-90:20pt);
  % fireworks
  \pgfmathparse{100-(\radius-1)*10};
  % red firework
  \ifnum\radius<11
      \draw[decorate,decoration={crosses},red!\pgfmathresult!black] (0,0) circle (\radius ex);
  \fi
  % orange firework
  \pgfmathparse{100-(\radius-6)*10};
  \ifnum\radius>5
      \ifnum\radius<16
          \draw[decorate,decoration={crosses},orange!\pgfmathresult!black] (1,1) circle ( \radius ex-5ex);
      \fi
  \fi
  % yellow firework
  \pgfmathparse{100-(\radius-11)*10};
  \ifnum\radius>10
      \draw[decorate,decoration={crosses},yellow!\pgfmathresult!black] (2.5,1) circle (\radius ex-10ex);
  \fi
\end{tikzpicture}
}
\end{document}

The resulting PDF file can be cropped and converted using

pdfcrop myfile.pdf
convert -delay 20 -loop 0 -density 300 myfile-crop.pdf fireworks.gif

Category: TeX.SX, pgf/TikZ | No Comments »

Happy Christmas!

Dezember 25th, 2012 by Stefan Kottwitz

Christmas tree

This Christmas tree has been written in LaTeX and TikZ by Alain Matthes. See the complete source code.

Category: pgf/TikZ, Graphics | No Comments »

New maintainer wanted for pgfSweave

August 5th, 2012 by Stefan Kottwitz

Cameron Bracken announced that he is looking for a new maintainer of the pgfSweave package. pgfSweave is an R package for use with Sweave for speedy compilation of high quality graphics, specifically it provides capabilities for “caching” graphics generated with Sweave. It has been created by Cameron Bracken and Charlie Sharpsteen, was available at CRAN but has now been removed until somebody would implement necessary changes.

Are you interested in continuing this project? Do you know LaTeX, R and Sweave, are you able to work with Git and Make, or willing to learn it? If you would like to contribute, just send Cameron a message.

Category: News, pgf/TikZ, Graphics | 2 Comments »

LaTeX and Graphics - Contest contributions

Juni 22nd, 2012 by Stefan Kottwitz

On LaTeX-Community.org, 10 authors have sent contributions to the “LaTeX and Graphics” contest.

Did you like an article? Or many? It would be great if you would

  • comment on it - what you liked, what further ideas do you have about this topic. Feedback is very welcome by authors. If you already read an article, it’s still a good idea to visit the article again and to comment on it.
  • blog about it - if you are a blogger. Tell your readers, which article you liked, what do you think about the contributions.
  • share it via Twitter, google+ or Facebook - there are buttons for it over and below each post. Spread the word about LaTeX!

It will be hard to decide, which authors would be the winners. You can help: show which contributions are the most liked by you!

Here are the nominees - please vote, comment and share!

Did you like the contest and some some contributions? Let the authors know!

Let’s review some time, then we will know who has won the prizes.

To have a quick glance, what the contributions show to us:

Surface plot
Plot
Parabola
Geometric drawing
Cube surfaces
3D surface plot
Tufte style chart

Category: News, Events, Graphics | No Comments »

LaTeX Contest - four days left

Juni 16th, 2012 by Stefan Kottwitz

The currently running “LaTeX and Graphics” article competition on LaTeX-Community.org will close on 20/06/12. Until now, very few users told me that they would make a contribution. Which means, there’s a good chance to win one of the gnuplot books.

Do you …

  • … have a blog you would like to mention?
  • … maintain a web site, people may visit?
  • … wrote a LaTeX related package, you would like to introduce to readers?
  • … would like to show what is possible with LaTeX, today?

This contest could be a nice opportunity for these points and more. Just add some lines about you as the author and your website or your software.

Even a small blog-like post would be very welcome. Feel free to contact me via email to stefan@latex-community.org or via the contact form. I can create an account for you both on the main and on the development server, so that you could even check the final layout before posting.

Category: News, Events, Graphics | No Comments »

Contest on LaTeX-Community.org - Win a gnuplot Book

Juni 4th, 2012 by Stefan Kottwitz

gnuplot Cookbook

LaTeX-Community.org has teamed up with Packt Publishing to organize a contest. Two users stand a chance to win a copy of the new book on gnuplot, the newly published gnuplot Cookbook written by Lee Phillips.

To enter the contest, write a small article for publishing on LaTeX-Community.org. The topic of this contest is: LaTeX and Graphics.

From the book’s web page:

gnuplot Cookbook – it will help you master gnuplot. Start using gnuplot immediately to solve your problems in data analysis and presentation. Quickly find a visual example of the graph you want to make and see a complete, working script for producing it. Learn how to use the new features in gnuplot 4.4. Find clearly explained, working examples of using gnuplot with LaTeX and with your own computer programming language.

You will learn to plot basic 2d to complex 3d plots, annotate from simple labels to equations, integrate from simple scripts to full documents and computer progams. You will be taught to annotate graphs with equations and symbols that match the style of the rest of your text, thus creating a seamless, professional document. You will be guided to create a web page with an interactive graph, and add graphical output to your simulation or numerical analysis program.

To read more details, have a look at the contest announcement and the book’s web page, including the entire table of contents and a sample chapter for download.


This text is available in German. Dieser Text ist auch in Deutsch verfügbar.

Category: News, Events, Graphics | No Comments »

Drawing a stemma with TikZ

März 31st, 2012 by Stefan Kottwitz

Maïeul Rouquette has published an article on LaTeX-Community.org: Stemma with TikZ. It is an English translation of his three French blog articles about that topic.

A stemma codicum is a “family tree” of different manuscripts of a same text, see Stemmatics (Wikipedia). The article explains how to draw such a tree, which is also a method for constructing TikZ trees in general:

  • For simple trees, use nodes, edges and children with the TikZ tree syntax
  • For complex trees, you can go through these steps:
    1. Place the nodes, using coordinates or relatiive positioning, and give them names
    2. Apply styles for the nodes, choose or define your own styles for this
    3. Connect nodes by lines or arrows such as by \draw[->] (node1) — (node2);
Stemma with Tikz

Once you have created such a tree, you could easily use this as a template for further trees, if you don’t like to go through such a construction process each time. Though some things seem to be complicated with TikZ, it’s easy to re-use and to adjust for similar drawings. For this, the TikZ example gallery can give good start code. It also provides some examples for TikZ trees.

Category: pgf/TikZ, Graphics | No Comments »

LaTeX Workflow

Januar 18th, 2012 by Stefan Kottwitz

Agodemar posted a very nice diagram of the LaTeX workflow on TeX.SX:

LaTeX Workflow - compiler and application levels

A bigger version of the image and a link the full source code is shown in the topic Diagram / Infographic of TeX & friends.

Category: TeX.SX, pgf/TikZ, LaTeX General | No Comments »

Happy New Year!

Januar 1st, 2012 by Stefan Kottwitz

Happy New Year, and the best wishes!

Fireworks

The image shows fireworks displayed with TikZ by percusse on TeX.SX. Follow the link to see further fireworks effects.

The code is:

\documentclass{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{0pt}%
\usetikzlibrary{calc,decorations.pathmorphing}
%
\pgfdeclareradialshading{someshade}{\pgfpointorigin}{%
  color(0mm)=(pgftransparent!40);color(5mm)=(pgftransparent!50);%
  color(10mm)=(pgftransparent!70);color(2cm)=(pgftransparent!100)}
\pgfdeclareradialshading{somenodeshade}{\pgfpointorigin}{%
  color(0mm)=(pgftransparent!0);color(2mm)=(pgftransparent!5);%
  color(5mm)=(pgftransparent!95);color(20mm)=(pgftransparent!100)}
\pgfdeclareradialshading{invertshade}{\pgfpointorigin}{%
  color(0mm)=(pgftransparent!100);color(6mm)=(pgftransparent!95);%
  color(10mm)=(pgftransparent!60);color(2cm)=(pgftransparent!0)}
\pgfdeclarefading{fadeit}{\pgfuseshading{someshade}}
\pgfdeclarefading{fadein}{\pgfuseshading{invertshade}}
%
\begin{document}
\begin{tikzpicture}[projectile/.style={decorate,decoration={random steps,
  segment length=3pt,amplitude=0.5pt}}]
  \fill[black] (-4,-4) rectangle (6,5);
 
  \begin{scope}[xshift=0cm,yshift=-0.4cm,transparency group]
    \pgfsetfading{fadein}{\pgftransformshift{\pgfpointorigin}}
    \foreach \x in {0,6,..., 360}{\draw[blue!80!white,projectile,line width=1.1pt]
      (0,0) to [in=90] (10*rand+\x:rand*1mm+2cm);};
  \end{scope}
 
  \begin{scope}[xshift=2cm,yshift=1cm]
    \foreach \x in {0,8,..., 360}{\draw [yellow!5,thick,projectile] (0.7,0)
      to  (3*rand+\x :1mm*rand+2.2cm)  node[circle,inner sep=1mm,
      shade,shading=somenodeshade,opacity=0.1] {};}
    {\pgfsetfading{fadeit}{\pgftransformshift{\pgfpoint{2.5cm}{1cm}}}};
    \fill[white] (-3,-3) rectangle (3,3);
  \end{scope}
 
  \begin{scope}[xshift=3cm,yshift=-1cm]
    \foreach \x in {0,10,..., 360}{\def\r1{rand}\draw [yellow]
      ($(0,0)!abs{\r1}!(\x :5mm)$) to [in=90] ($(0,0)!abs{\r1}+0.2!(\x :8mm)$);}
    {\pgfsetfading{fadeit}{\pgftransformshift{\pgfpoint{3cm}{-1cm}}}};
    \fill[yellow,opacity=0.6] (-3,-3) rectangle (3,3);
  \end{scope}
 
  \begin{scope}[xshift=-1cm,yshift=1.5cm]
    \foreach \x in {0,12,..., 360}{\def\r2{rand}\draw [red,line width=0.5pt]
      ($(0,0)!abs{\r2}!(\x :3mm)$) -- ($(0,0)!abs{\r2}+0.1!(\x :7mm)$);}
    {\pgfsetfading{fadeit}{\pgftransformshift{\pgfpoint{-1cm}{1.5cm}}}};
    \fill[red,opacity=0.6] (-3,-3) rectangle (3,3);
  \end{scope}
\end{tikzpicture}
\end{document}

The image has been taken from the TeXworks PDF previewer, not all PDF viewers are capable of showing it in this quality. The example has been added to the TikZ example gallery.

Category: TeX.SX, pgf/TikZ | 1 Comment »

Merry Christmas!

Dezember 24th, 2011 by Stefan Kottwitz

Christmas tree

This Christmas tree has been created by Mikko Heiskanen with this code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{scopes,svg.path,shapes.geometric,shadows}
\begin{document}
\begin{tikzpicture}[
  mystar/.style={star, minimum size=2cm, star point ratio=2.5, shade, thick,
    line join=round, color=yellow!80!black, draw=red!20!black,
    top color=yellow!80!white, bottom color=yellow!60!black},
  mytree/.style={scale=0.5, rotate=180, draw=green!60!black, thick,
    line join=round, inner color=green!60!yellow, outer color=green!50!black},
  myball/.style={shade, ball color=#1, circular drop shadow={
    shadow xshift=0pt, shadow yshift=-.5ex, fill=green!40!black}}
  ]
  {[mytree]
  \shadedraw svg "M355,430
    q90,10 105,-85 30,0 50,-30 20,30 50,30 50,-20 100,0 10,88 105,85
    -45,90 -205,25 Q400,520 355,430";
  \shadedraw svg "M380,325
    q83,10 105,-80 25,0 35,-30 20,25 40,30 20,-10 35,-25 20,20 40,25
    25,90 105,82 -15,50 -120,15 -30,-2 -60,12 -30,0 -52,-28
    C490,370 380,360 380,325";
  \shadedraw svg "M435,225
    q65,-8 90,-70 35,40 70,0 25,60 90,70 -30,52 -90,5 -36,48 -73,-3
    C520,254 445,265 435,225";
  \shadedraw svg "M470,139
    q50,5 90,-80 50,90 90,80 -30,30 -50,20 -40,45 -78,0
    Q500,170 470,139";
  }
  %\shadedraw svg[scale=0.5,rotate=180]
  %"M460,532 q50,-8 q77,-45 v-20 a20,13 0 1 1 48,0 v20 q30,40 77,45";
  %pgf/tikz doesn't like the arc operation, as stated in manual
 
  \node[mystar] at (-9.85,-1) {$\lambda$};
 
  \shade[myball=blue]   (-9.7,-2.2)   circle (.2cm);
  \shade[myball=red]    (-9.2,-3.8)   circle (.2cm);
  \shade[myball=green]  (-10.3,-4)    circle (.4cm);
  \shade[myball=yellow] (-8.95,-5.4)  circle (.4cm);
  \shade[myball=red]    (-10.7,-6.1)  circle (.4cm);
  \shade[myball=blue]   (-10.8,-5)    circle (.2cm);
  \shade[myball=yellow] (-9.5,-6.7)   circle (.2cm);
  \shade[myball=green]  (-8.3,-7.6)   circle (.4cm);
  \shade[myball=yellow] (-11.7,-7.6)  circle (.4cm);
  \shade[myball=blue]   (-10.5,-7.8)  circle (.2cm);
\end{tikzpicture}
\end{document}

Further trees based using TikZ and pgfplots, using decorations and L-System fractals are here: Christmas trees with TikZ.

Category: TeX.SX, Events, pgf/TikZ | No Comments »