在函数末尾添加一个小箭头

在函数末尾添加一个小箭头

我有以下一段代码tikz

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=3cm,y=2cm]
            \draw[->,color=black] (-0.9,0.) -- (1.9,0.);
            \foreach \x in {}
            \draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {\footnotesize $\x$};
            \draw[->,color=black] (0.,-2.4) -- (0.,2.4);
            \foreach \y in {}
            \draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {\footnotesize $\y$};
            \draw[color=black] (0pt,-10pt) node[right] {};
            \clip(-0.9,-2.4) rectangle (1.9,2.4);
            \draw[<->,line width=1.2pt,color=qqqqff,smooth,samples=100,domain=-0.9:1.9] plot(\x,{3.0*(\x)^(3.0)-5.0*(\x)^(2.0)+(\x)+1.0});
            \draw[line width=1.2pt,color=ffqqqq,smooth,samples=100,domain=-0.9:1.9] plot(\x,{9.0*(\x)^(2.0)-10.0*(\x)+1.0});
            \draw [dash pattern=on 1pt off 1pt] (0.11111111164602015,-4.279272269869239E-9)-- (0.11111111164602015,1.0534979423868314);
            \draw (-0.32,0.05) node[anchor=north west] {$\frac{1}{3}$};
            \draw (0.06,0.07) node[anchor=north west] {$\frac{1}{9}$};
            \draw (0.52,0.03) node[anchor=north west] {$\frac{5}{9}$};
            \draw [dash pattern=on 1pt off 1pt] (0.54,0.54)-- (0.54,0.);
            \draw (0.24,0.70) node[anchor=north west] {\tiny{Punto de inflexión}};
            \draw (0.11,1.25) node[anchor=north west] {\tiny{máximo}};
            \draw (0.8,1.37) node[anchor=north west] {$C'(x)$};
            \draw (1.15,1.21) node[anchor=north west] {$C(x)$};
            \draw (0.98,-0.20) node[anchor=north west] {\tiny{mínimo}};
            \end{tikzpicture}

结果是: 在此处输入图片描述

我想要这样的结果 在此处输入图片描述

我怎样才能做到这一点?

答案1

您可以使用<->或放置标记装饰。但问题是您正在剪切曲线。因此很难找到终点。因此,您必须仔细调整域,以便曲线的终点位于剪切区域内。这是一个示例:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,arrows.meta,decorations.markings}
\tikzset{myarrow/.style={draw,decoration={markings, mark=at position 0 with {\arrow{<}},mark=at position 1 with {\arrow{>}}},postaction={decorate}}
}
\begin{document}
  \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=3cm,y=2cm]
            \draw[->,color=black,] (-0.9,0.) -- (1.9,0.);
            \foreach \x in {}
            \draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {\footnotesize $\x$};
            \draw[->,color=black] (0.,-2.4) -- (0.,2.4);
            \foreach \y in {}
            \draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {\footnotesize $\y$};
            \draw[color=black] (0pt,-10pt) node[right] {};
            \clip(-0.95,-2.5) rectangle (1.95,2.5);
            \draw[<->,line width=1.2pt,color=orange,samples=100,domain=-0.6:1.65] plot(\x,{3.0*(\x)^(3.0)-5.0*(\x)^(2.0)+(\x)+1.0});
            \draw[myarrow,line width=1.2pt,color=brown,samples=100,domain=-0.11:1.235] plot(\x,{9.0*(\x)^(2.0)-10.0*(\x)+1.0});
            \draw [dash pattern=on 1pt off 1pt] (0.11111111164602015,-4.279272269869239E-9)-- (0.11111111164602015,1.0534979423868314);
            \draw (-0.32,0.05) node[anchor=north west] {$\frac{1}{3}$};
            \draw (0.06,0.07) node[anchor=north west] {$\frac{1}{9}$};
            \draw (0.52,0.03) node[anchor=north west] {$\frac{5}{9}$};
            \draw [dash pattern=on 1pt off 1pt] (0.54,0.54)-- (0.54,0.);
            \draw (0.24,0.70) node[anchor=north west] {\tiny{Punto de inflexión}};
            \draw (0.11,1.25) node[anchor=north west] {\tiny{máximo}};
            \draw (0.8,1.37) node[anchor=north west] {$C'(x)$};
            \draw (1.15,1.21) node[anchor=north west] {$C(x)$};
            \draw (0.98,-0.20) node[anchor=north west] {\tiny{mínimo}};
            \end{tikzpicture}
\end{document}

在此处输入图片描述

这是一个示例pgfplots。我刚刚绘制了曲线,其他内容留作练习。

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{arrows}
\begin{document}
  \begin{tikzpicture}[>=triangle 45,]
    \begin{axis}[width=\linewidth,
            axis lines=center,
            xmin=-1,xmax=3,
            ymin=-3,ymax=3,
            axis line style={->}
            ]
      \addplot+[<->,mark=none,line width=1pt,samples=100,domain=-0.6:1.65] {3*(x^3)-5*(x^2)+x+1};
       \addplot+[<->,mark=none,line width=1pt,samples=100,domain=-0.145:1.25] {9*(x^2)-10*(x)+1};
    \end{axis}
  \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容