6

I edited my code to fill the area and plot the round arrow. The arrowhead shows upwards as shown here:

http://www.directupload.net/file/d/3751/q4ohidu4_pdf.htm

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{ngerman}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{pgfplots}
\usepackage{color}
\begin{document}
\definecolor{darkred}{rgb}{1.0,0.2,0.2}

\begin{figure} 
\begin{tikzpicture}
 %\draw[help lines] (0,0) grid (10,10);
 \draw [->, thick] (-3,0) -- (0,0) -- (3,0);
 \node at (3.2,0) {$\vec{k}$};
 \draw [->, thick] (0,0) -- (0,5);
 \node at (0,5.5) {$\varepsilon(\vec{k})$};
 \draw [thick, domain=-2:2] plot (\x, {\x*\x});
 \draw [thick, dashed] (-2,3.0) -- (2,3.0);
 \draw [fill, red] (1,3) circle [radius=0.05];
 \draw [fill, red] (2,4.2) circle [radius=0.05];
 \draw [fill, red] (3,2) circle [radius=0.05]; 
 \draw [thick] (2.5,2) -- (3.5,2);
 \draw [->, thick] (3,1.70) -- (3,2.30);
 \begin{scope}
    \clip [domain=-2:2]plot (\x, {\x*\x});
    \fill [darkgray, opacity=0.4] (-2,0) rectangle (2,3);
 \end{scope}
 \draw[thick,-stealth] plot [smooth,tension=.55] coordinates {(3.0,2.0) (2,4.2) (1.0,3.0)};
\end{tikzpicture}
\end{figure}

\end{document}
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Sep 20 '14 at 16:31
  • I compiled your code here and I got the right result (arrow pointing downward). I suspect you are running a not-up-to-date version of TikZ, can you check what version are you running? – Nico Vecchio Sep 20 '14 at 22:10
  • Hey, how can I check / update my version of TikZ? I'm using Kile for working and the basic version of TikZ which was automatically installed with Kile. – Deuterium42 Sep 21 '14 at 11:29
  • @Deuterium42 Could you join the following chat room? It is a bit difficult to go through this inside comments: chat.stackexchange.com/rooms/17317/… – Nico Vecchio Sep 21 '14 at 16:43
  • Hey, I just have 11 reputation and need 20 to use the chat. – Deuterium42 Sep 21 '14 at 17:14
3

Maybe like this:

 \documentclass{article}
 \usepackage{tikz}
 \begin{document}
 \begin{tikzpicture}
 \draw[help lines] (0,0) grid (10,10);

 \draw [->, thick] (-3,0) -- (0,0) -- (3,0);
 \node at (3.2,0) {$\vec{k}$};
 \draw [->, thick] (0,0) -- (0,5);
 \node at (0,5.5) {$\varepsilon(\vec{k})$};
 \draw [thick, domain=-2:2] plot (\x, {\x*\x});
 \begin{scope}
    \clip [domain=-2:2]plot (\x, {\x*\x});
    \fill [blue, opacity=0.4] (-2,0) rectangle (2,3);
 \end{scope}
 \draw [thick, dashed] (-2,3.0) -- (2,3.0);
 \draw [fill, red] (1,3) circle [radius=0.05];
 \draw [fill, red] (2,4.2) circle [radius=0.05];
 \draw [fill, red] (3,2) circle [radius=0.05];
 \draw [thick] (2.5,2) -- (3.5,2);
 \draw[thick,-stealth] plot [smooth,tension=.55] coordinates {(3.0,2.0) (2,4.2) (1.0,3.0)};
\end{tikzpicture}
 \end{document}

You need to clip the parabola for the filling. To connect the points you can use a plot with coordinates. The tension option will change the "roundness" of the curve, .55 is the default value.

enter image description here

| improve this answer | |
  • Hi, tanks for your fast answer. I added your lines and the filling works. But I got a little problem with the arrow. The arrow is smooth now, but the arrow head does not point at the red dot. In my file it points upwards ... any idea why? – Deuterium42 Sep 20 '14 at 17:55
  • @Deuterium42 If you copy-paste the following line \draw[thick,-stealth] plot [smooth,tension=.55] coordinates {(3.0,2.0) (2,4.2) (1.0,3.0)};exactly as it is into your code you got a different result than the one in the picture? – Nico Vecchio Sep 20 '14 at 18:05
  • Yes. I retried (copy + paste) it but still the same problem. Is it possible to upload the picture and show it to you? If yes, how? – Deuterium42 Sep 20 '14 at 18:09
  • @Deuterium42 you can edit the question and insert a link to some service where you have uploaded the image. I suggest to edit the question, insert the new code (with the modification taken from my answer) in a compilable form and the link to the result you got when compiling. – Nico Vecchio Sep 20 '14 at 18:23
4

With pgfplots:

\documentclass[border=5]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usepgfplotslibrary{fillbetween}
\begin{document}
   \begin{tikzpicture}
     \begin{axis}[
     axis lines=middle,
    axis equal,
    grid=both,
    xlabel=$\vec{k}$,
    ylabel=$ε(\vec{k})$,
    no marks,
    domain=-2:2,
    xmax=4,xmin=-3,ymax=3,ymin=0,samples=100,
    ]
       \addplot[red,thick,name path=a] {(x^2)};
       \addplot[blue,thick,name path=b,dashed] {2} ;
       \addplot[fill=none] fill between[of=a and b,split,
           every segment no 1/.style={fill,orange,opacity=.4},] ;
       \draw [fill, red] (axis cs: 1,3) circle [radius=0.05];
        \draw [fill, red] (axis cs: 2,4.2) circle [radius=0.05];
        \draw [thick] (axis cs: 2.5,2) -- (axis cs: 3.5,2);
        \draw [fill, red] (axis cs: 3,2) circle [radius=0.05];
        \addplot[->,thick,smooth,samples=100] coordinates{
       (3.0,2.0) (2,4.2) (1.0,3.0)};
     \end{axis}
   \end{tikzpicture}
\end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.