Graphics, Figures & TablesTikz: Hashing and labeling with arrows

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
jhapk
Posts: 81
Joined: Tue Apr 20, 2010 9:33 pm

Tikz: Hashing and labeling with arrows

Post by jhapk »

Hi,

I have written the following tikz code

Code: Select all

\documentclass{minimal}
\usepackage{tikz}

\begin{document}
\pagestyle{empty}
\begin{tikzpicture}

  \draw[step=.5cm,gray,very thin] (-1,-1) grid (15,15);

  % nozzles 
  \begin{scope}[ultra thick]
    %% upper nozzle
    \draw (6,10) -- (10,10);
    \draw (6,10) .. controls (6,11.5) and (4,12) .. (4,12);
    \draw (10,10) .. controls (10,11.5) and (12,12) .. (12,12);
    %% lower nozzle
    \draw (6,3) -- (10,3);
    \draw (6,3) .. controls (6,1.5) and (4,1) .. (4,1);
    \draw (10,3) .. controls (10,1.5) and (12,1) .. (12,1);
  \end{scope}

  % stagnation plane
  \draw [dashed, thick](4,6.5) -- (12,6.5);

  % flame
  \draw [<-][fill=red](4.5,7.25) rectangle (11.5,7.4) node [above right,inner sep=4pt] {Flame};

  % streamlines
  \begin{scope}[very thick,>=stealth]
    %% upper 
    \begin {scope}[blue]
      \draw [->] (6.5,10) .. controls (6.5,8) and (5.5,6.75) .. (4.5,6.75);
      \draw [->] (7.5,10) .. controls (7.5,8) and (6.5,6.75) .. (5.5,6.75);
      \draw [->] (8.5,10) .. controls (8.5,8) and (9.5,6.75) .. (10.5,6.75);
      \draw [->] (9.5,10) .. controls (9.5,8) and (10.5,6.75) .. (11.5,6.75);
    \end {scope}
    %% lower
    \begin{scope}[green]
      \draw [->] (6.5,3) .. controls (6.5,5) and (5.5,6.25) .. (4.5,6.25);
      \draw [->] (7.5,3) .. controls (7.5,5) and (6.5,6.25) .. (5.5,6.25);
      \draw [->] (8.5,3) .. controls (8.5,5) and (9.5,6.25) .. (10.5,6.25);
      \draw [->] (9.5,3) .. controls (9.5,5) and (10.5,6.25) .. (11.5,6.25);
    \end{scope}
  \end{scope}

\end{tikzpicture}
\end{document}
This gives me the following image
Screenshot.png
Screenshot.png (13.77 KiB) Viewed 3151 times


I am trying to make something like the scanned image below. I am not sure how to put the labels with arrows from text to the lines? Also, how do I show the solid surfaces as shown in the scanned image (the hashed regions)?
sorry about the bad image quality, its scanned from a book
sorry about the bad image quality, its scanned from a book
counter.jpeg (7.94 KiB) Viewed 3151 times
Thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

torbjorn t.
Posts: 162
Joined: Wed Jun 17, 2009 10:18 pm

Tikz: Hashing and labeling with arrows

Post by torbjorn t. »

Not sure how to do the hashed region. One way of doing the arrow from label to line is like this:

Code: Select all

\documentclass{minimal}
\usepackage{tikz}

\usetikzlibrary{positioning}

\begin{document}
\pagestyle{empty}
\begin{tikzpicture}

  \draw[step=.5cm,gray,very thin] (-1,-1) grid (15,15);

  % nozzles 
  \begin{scope}[ultra thick]
    %% upper nozzle
    \draw (6,10) -- (10,10);
    \draw (6,10) .. controls (6,11.5) and (4,12) .. (4,12);
    \draw (10,10) .. controls (10,11.5) and (12,12) .. (12,12);
    %% lower nozzle
    \draw (6,3) -- (10,3);
    \draw (6,3) .. controls (6,1.5) and (4,1) .. (4,1);
    \draw (10,3) .. controls (10,1.5) and (12,1) .. (12,1);
  \end{scope}

  % stagnation plane
  \draw [dashed, thick](4,6.5) -- (12,6.5);

  % flame
  \draw [<-][fill=red](4.5,7.25) rectangle (11.5,7.4) node (flame) {};

  % flame label
  \node (flametext) [above right=of flame] {Flame};
  % arrow
  \draw [->] (flametext) -- (flame);

  % streamlines
  \begin{scope}[very thick,>=stealth]
    %% upper 
    \begin {scope}[blue]
      \draw [->] (6.5,10) .. controls (6.5,8) and (5.5,6.75) .. (4.5,6.75);
      \draw [->] (7.5,10) .. controls (7.5,8) and (6.5,6.75) .. (5.5,6.75);
      \draw [->] (8.5,10) .. controls (8.5,8) and (9.5,6.75) .. (10.5,6.75);
      \draw [->] (9.5,10) .. controls (9.5,8) and (10.5,6.75) .. (11.5,6.75);
    \end {scope}
    %% lower
    \begin{scope}[green]
      \draw [->] (6.5,3) .. controls (6.5,5) and (5.5,6.25) .. (4.5,6.25);
      \draw [->] (7.5,3) .. controls (7.5,5) and (6.5,6.25) .. (5.5,6.25);
      \draw [->] (8.5,3) .. controls (8.5,5) and (9.5,6.25) .. (10.5,6.25);
      \draw [->] (9.5,3) .. controls (9.5,5) and (10.5,6.25) .. (11.5,6.25);
    \end{scope}
  \end{scope}

\end{tikzpicture}
\end{document}
The positioning library is loaded to place the label node relative to the node at the end of the flame line.

Should you wish a curved arrow, you could write

Code: Select all

\draw [->] (flametext) to[bend left=20] (flame);
in stead of

Code: Select all

\draw [->] (flametext) -- (flame);
Post Reply