如何绘制抛物线图及其切线

如何绘制抛物线图及其切线

我想使用 pgfplots 绘制 y=x^2 的抛物线图,并绘制切线和图形之间的切线和角度,如图所示,有谁能帮帮我吗?

这种类型的图表

答案1

tkz-fct / TikZ

\documentclass{standalone}
\usepackage{tkz-fct}
\begin{document}
\begin{tikzpicture}[scale=2] \tkzInit[xmax=2,ymax=4] 
\tkzGrid  \tkzAxeXY
\tkzFct[color = red,thick, domain =0:2]{x*x}
\tkzDrawTangentLine[draw, kl = 0.8, kr = 0.8](0) 
\tkzDrawTangentLine[draw, kl = 0.8,kr = 0.8 ](1) 
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

看一看:

\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.9}

\begin{tikzpicture}
\begin{axis}
\addplot[color=red]{x^2};
\addplot[color=blue]{0};
\end{axis}
\end{tikzpicture}

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

答案3

尝试这个(使用 TikZ):

\documentclass[a4paper]{article}
\usepackage{tikz}
\begin{document}
    \centering
    \begin{tikzpicture}[line width=3pt,scale=1.5]
        \draw [gray!10,line width=.3pt] (-3,-1) grid (3,5);     
        \draw [->,style=thick] (-3.2,0) -- (3.3,0) node[pos=1,right] {$x$}; 
        \foreach \x in {-3,...,3} \draw[thick] (\x,-0.05) to (\x,0.05) node[black,below] at (\x,-0.05) {$\x$}; 
        \draw [->,style=thick] (0,-1.20) -- (0,5) node[pos=1,right] {$y$}; 
        \foreach \x in {-1,...,5} \draw[thick] (-0.05,\x) to (0.05,\x) node[black,left] at (-0.05,\x) {$\x$};
        \draw [cyan, domain=-2.2:2.2, samples=50] plot (\x, {\x*\x }); %parabola
        \draw [magenta, domain=0:3, samples=50] plot (\x, {2*\x- 1}); % tangent in x=1
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容