2

I just want to use something like .. controls .. in an addplot command. Unfortunately, the option "smooth" does not produce the image I desire. I haven't found it in the manual so far. The reason I'm not uusing tikz directly, is because i want to use the legend of pgfplots.

Any other ideas? If necessary I will post a MWE.

Edit: It is not really a MWE but i hope it helps. I couldn't use draw with controls in axis (even though I expressed the coordinates in the axis cs). The red "graph" is only shows how i want the blue line to be bend

\documentclass{minimal}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
 \addplot[blue,thick] coordinates
 {(0,0)(0.2,0)(0.8,1)(1,1)};
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}[scale=5]
  \draw[red] (0,0) .. controls (0.2,0) and (0.8,1)
 .. (1,1);
\end{tikzpicture}
\end{document}
  • 2
    A MWE is a very good idea. – Thorsten Donig Feb 9 '14 at 9:55
  • 1
    Maybe worth a look: Why should the minimal class be avoided?. – Tobi Feb 9 '14 at 11:09
  • Thanks, the minimal class seems to cause lots of problems here, without it, I find the correct graph, though still obtaining some errors, which are probably due to a wrong coordinate system. (axis cs:0,0) seems to cause problems. – Quickbeam2k1 Feb 9 '14 at 11:23
5

You can access the coordinate system, which is used to plot functions by axis cs as in

\draw (axis cs:0,0) -- (axis cs:1,1);

For more on accessing axis coordinates in graphical elements, see section 4.17.1 on page 290 of the pgfplots manual.

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
    \begin{axis}
        \addplot[blue,thick] coordinates {(0,0)(0.2,0)(0.8,1)(1,1)};
        \draw[red] (axis cs:0,0) .. controls (axis cs:0.2,0) and (axis cs:0.8,1) .. (axis cs:1,1);
    \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

  • thanks, essentially, the minimal document class caused the problems. – Quickbeam2k1 Feb 9 '14 at 21:40

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.