在函數末尾添加一個小箭頭

在函數末尾添加一個小箭頭

我有以下一段程式碼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}

在此輸入影像描述

相關內容