3 点画抛物线

3 点画抛物线
\begin{tikzpicture}[scale=1.6]
    \begin{axis}[
                 xmin=-0.02,xmax=0.12,
                 ymin=-2,ymax=15,legend style={nodes={scale=0.6, transform shape}}, 
        legend image post style={mark=*}, xlabel=$Axialrichtung (mm)$,ylabel=$Spannung (MPa)$]
    \addplot[only marks,mark=*,blue] table{O-ring2-N-0.2.txt};

     \draw[red] (axis cs: -0.02, 0) -- (axis cs: 0, 11.045);
     \draw[red](axis cs: 0,11.045) parabola bend ( axis cs: 0.1,0) (axis cs: 0,-11.045) ;
    \end{axis}
\end{tikzpicture}

在此处输入图片描述

应该是一条向左开口的抛物线,而不是两条向上下开口的0.5倍抛物线。我错在哪里了?

答案1

欢迎来到本网站!您需要旋转抛物线,标准构造仅适用于“直立”抛物线。还请提供完整的代码。更多信息可以在以下(完整)代码的注释中找到。

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
%\pgfplotsset{compat=1.16}%<- it would be better to use the latest version
\begin{document}
\begin{tikzpicture}
    \begin{axis}[scale=1.6,%<- put scale into the axis options
                 xmin=-0.02,xmax=0.12,
                 ymin=-2,ymax=15,legend style={nodes={scale=0.6, transform shape}}, 
        legend image post style={mark=*}, xlabel={Axialrichtung (mm)},
        ylabel={Spannung (MPa)}]%<- removed math mode
    %others do not have your data files 
    %\addplot[only marks,mark=*,blue] table{O-ring2-N-0.2.txt};
     \draw[red] (axis cs: -0.02, 0) -- (axis cs: 0, 11.045);
    %define symbolic coordinates (don't get transformed) 
     \path (axis cs: 0,11.045) coordinate (tmp1)
      (axis cs: 0.1,0) coordinate (tmp2) (axis cs: 0,-11.045) coordinate (tmp3);
    %draw *rotated* parabola
     \draw[red,rotate=90] (tmp1) parabola bend (tmp2) (tmp3) ;
    \end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容