# Create diagrams in LaTeX with TikZ

I am relatively new to the concept of generating diagrams in LaTeX, and do not know if LaTeX is capable of generating the diagram i wish to create. The diagram looks like this:

I was hoping someone could point me in the right direction as to how I would go around creating a diagram like this. FYI this was generated in Powerpoint, and when I insert it as an image in LaTeX, the resolution is very poor, also I would eventually like to add some text to the diagram. I have started using TikZ, and am learning a lot as I read through the manual, but I cant see how I can create diagrams like the one shown here.

Edited: Eventually I wish to add some text on the diagram showing some of the processes that occur within the water column. At the moment I have simply generated the features of the diagram individually i.e. create a sine wave for the surface, used 'tension' for the shape of the lake, and then connect these together with straight lines. It just seems that the method that I'm adopting is rather long winded, and wont end up producing a nice outcome.

• In the manual, in section 2.4 Curved Path Construction (page 25) you will find some info about how to create curves. By the way, may be (if you don't need exact curves) you could see section 19.8 (page 225) where the manual talks about tension. Not optimal, but let you create easily curves like that: \draw[smooth] plot[tension=0.7] coordinates{(-5.5,3.5) (-4,3) (-3,1) (0,0) (3,1) (4,3) (5.5,3.5)};. Jan 23, 2013 at 17:32
• How exactly you generate this probably depends on what you want to do with it later on. Do you need to generate lots of different but similar diagrams (different water levels, different lake shapes, maybe)? If you could provide a bit more information, both about what you're trying to do and where you're stuck, I'm sure you'll get some pretty awesome answers here.
– Jake
Jan 23, 2013 at 18:30
• I don't need to generate additional diagrams but I will need to add additional features to this diagram e.g. some equations for the processes occurring. Jan 23, 2013 at 18:47
• @Kate I didn't notice your edit when I posted my answer. Sorry for that. Jan 23, 2013 at 19:29

Update: Improved code, and explanations and more examples added (after the first figure).

This is a "craftsman" solution, in which I fine-tuned a bit the control points for the bottom of the pit.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing,calc}
\begin{document}
\usetikzlibrary{decorations.pathmorphing,calc}
\begin{tikzpicture}
% Define some reference points
% The figure is drawn a bit bigger, and then clipped to the following dimensions:
\coordinate (clipping area) at (10, 7);
\clip (0,0) rectangle (clipping area);

% Next reference points are relative to the lower left corner of the clipping area
\coordinate (water level) at (0, 6);
\coordinate (bottom)      at (5, 1.3);     % (bottom of the pit)
\coordinate (ground1)     at (0, 5);       % (left shore)
\coordinate (ground2)     at (10, 5);      % (right shore)

% Coordinates of the bigger area really drawn
\coordinate (lower left)  at ([xshift=-5mm, yshift=-5mm] 0,0);
\coordinate (upper right) at ([xshift=5mm,  yshift=5mm] clipping area);

% Draw the water and ripples
\draw [draw=blue!80!black, decoration={bumps, mirror, segment length=6mm}, decorate,
bottom color=cyan!60!black, top color=blue!20!white]
(lower left) rectangle (water level-|upper right);

% Draw the ground
\draw [draw=brown!30!black, fill=brown]
(lower left) -- (lower left|-ground1)  --
(ground1) .. controls ($(ground1)!.3!(bottom)$) and (bottom-|ground1) ..
(bottom) .. controls (bottom-|ground2) and ($(ground2)!.3!(bottom)$) ..
(ground2) -- (ground2-|upper right) -- (lower left-|upper right) -- cycle;

% \draw[dotted](0,0) rectangle (clipping area);

\end{tikzpicture}
\end{document}


Result:

Some explanations:

• The figure is drawn bigger than the area shown, then it was clipped . This makes easier to draw the water and to remove the borders of the ground. In order to clarify this, you can reveal the clipping area by removing the line starting with \clip and adding at the end of the figure the line:

\draw[dotted](0,0) rectangle (clipping area);


You'll get:

• I made great use of intersection coordinate system, i.e.: the syntax (node1|-node2), meaning "the coordinate located at the vertical of node1 and the horizontal of node2, that is, located at (node1.x, node2.y) (if this syntax were possible in tikz)

• I defined a number of "reference points" to make easier the customization of the figure. For example, the figure can be made assymetrical changing the y coordinate of ground2, For example:

\coordinate (ground2)     at (10, 3);      % (right shore)


(See the result after the following bullet)

• The origin (0,0) is located at the lower left corner of the clipping area, so that it is easier to add labels at specified points, but you can also use the named coordinates (bottom), (water level) and so on, and use relative coordinates to achieve greater simplicity and flexibility. For example:

\draw[>=stealth, <->] (bottom) -- (bottom|-water level) node[right, midway] {7m};
\draw[>=stealth, <-] ([shift={(-3mm,-8mm)}] ground2) -- +(-1,2) node[above] {Plateau};


The result of adding these lines (and also changing the vertical position of (ground2) is the following:

• Great, really well done. Jan 23, 2013 at 22:07
• Could you please provide some additional explanation for the following 2 lines: \coordinate (aux2) at ([yshift=2cm] water level); \clip (.5,.5) rectangle (figure width|-aux2); I think I understand most of the code prior to those line. Jan 23, 2013 at 23:22
• @Kate I integrated my explanations in the answer, and added some additional remarks. Jan 24, 2013 at 8:50

This is a fairly unorthodox way that came to my mind:

\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[domain=-1.12:1.12,samples=150]
\fill[fill=brown] (-1.12,-0.2) -- plot [domain=-1.12:1.12] (\x,{sin((\x)^4 r)}) -- (1.12,-0.2) -- cycle;
\shadedraw[top color=cyan,bottom color=blue,draw=none](-1.12,1.2) -- plot [domain=-1.12:1.12] (\x,{sin((\x)^4 r)}) -- (1.12,1.2) -- cycle;
\end{tikzpicture}
\end{document}


Resulting in this: