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}
3
  • 2
    A MWE is a very good idea. Commented Feb 9, 2014 at 9:55
  • 1
    Maybe worth a look: Why should the minimal class be avoided?.
    – Tobi
    Commented Feb 9, 2014 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. Commented Feb 9, 2014 at 11:23

1 Answer 1

6

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

1
  • thanks, essentially, the minimal document class caused the problems. Commented Feb 9, 2014 at 21:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .