多项式根标记 tikzpicture

多项式根标记 tikzpicture

我想标记下列多项式的根:

\begin{center}
\begin{tikzpicture}[scale=1.2,thick]
\draw[->](-3mm,0mm)--(36mm,0mm) node at (34mm,-2.4mm){$p$};
%       \draw[shift={(+0.5,0)}] (0pt,2pt) -- (0pt,-2pt) node[below] {$\bar{p}$}
\draw[->](0mm,-3mm)--(0mm,14mm) node[above] {$\beta  p^2-p (\beta +\kappa \sigma     +1)+1$};
\draw[domain=-0.05:2] plot(\x,{((\x-0.5))*(\x-1.2)});
\end{tikzpicture}
\end{center}

任何帮助都值得感激。shift 方法似乎无法编译。

答案1

;正如 ferahfeza 评论的那样,您在尝试手动标记交叉点时遗漏了尾随:

在此处输入图片描述

Tikz是一个绘图包。对于绘图,你应该使用pgfplots专门为此目的设计的:

在此处输入图片描述

代码:

\documentclass[border=3pt]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}[scale=1.2,thick]
\draw[->](-3mm,0mm)--(36mm,0mm) node at (34mm,-2.4mm){$p$};
       \draw[shift={(+0.5,0)},red] (0pt,2pt) -- (0pt,-2pt) node[below] {$\bar{p}$};
\draw[->](0mm,-3mm)--(0mm,14mm) node[above] {$\beta  p^2-p (\beta +\kappa \sigma     +1)+1$};
\draw[domain=-0.05:2] plot(\x,{((\x-0.5))*(\x-1.2)});
\end{tikzpicture}
%
\begin{tikzpicture}
\begin{axis}[
    clip=false,
    ylabel={$\beta  p^2-p (\beta +\kappa \sigma +1)+1$},
    xlabel=$p$,
    axis lines=middle,
    xticklabels={},% if you don't want x tick labels
    yticklabels={},% if you don't want y tick labels
    xtick=\empty,% if you don't want x ticks
    ytick=\empty,% if you don't want y ticks
    extra x ticks={0.5,1.2},
    extra x tick labels={$\color{red}\bar{p}$,1.2},
    extra tick style={major tick length=5pt, tick style={red, line width=0.1em}},
    ]

    \addplot[domain=-0.05:2, samples=100, blue, ultra thick] plot(\x,{((\x-0.5))*(\x-1.2)});
\end{axis}
\end{tikzpicture}

\end{document}

答案2

在 tikz 手册中查找 intesections 库。

路口

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[scale=1.2,thick]
\draw[->,name path=zero](-3mm,0mm)--(36mm,0mm) node at (34mm,-2.4mm){$p$};
%       \draw[shift={(+0.5,0)}] (0pt,2pt) -- (0pt,-2pt) node[below] {$\bar{p}$}
\draw[->](0mm,-3mm)--(0mm,14mm) node[above] {$\beta  p^2-p (\beta +\kappa \sigma     +1)+1$};
\draw[domain=-0.05:2,name path=poly] plot(\x,{((\x-0.5))*(\x-1.2)});
\fill [red, opacity=0.5, name intersections={of=poly and zero}]
(intersection-1) circle (2pt) node {1}
(intersection-2) circle (2pt) node {2};
\end{tikzpicture}
\end{document}

相关内容