网格从 Tikz 到 Tkz-euclide

网格从 Tikz 到 Tkz-euclide

我在 Ti 中有此代码Z 运行良好,但我需要对 做同样的事情tkz-euclide。我的问题是:

  1. 如何制作这些tkz-euclide
  2. 如何将 x 轴名称从 x 更改为 M?
  3. 如何将 y 轴名称从 y 更改为 N?
  4. 如何使 x 轴和 y 轴的范围不同(x 轴从 -2 到 12,y 轴从 -20 到 100)?
  5. 水平括号和垂直括号怎样画?
  6. 如何在 x 轴和 y 轴的每一边末端画箭头?
  7. 如何使用\tkzInit, \tkzAxeXY,\tkzGrid来实现这一点?
\documentclass[border=20pt]{standalone}
\usepackage[margin=2cm]{geometry}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usepackage{pgfplots}
\usepackage{amsmath,amssymb}
\usepackage{bm,fixmath}
\usepackage{mathtools}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,snakes}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xshift=9cm,
    xmin=-2,xmax=13.1,
    ymin=-30,ymax=105,
    grid={both},
grid style={line width=.1pt, draw=cyan},
    major grid style={line width=.2pt,draw=cyan},
    axis lines={middle},
    minor tick num=1,
    enlargelimits={abs=0.25},
    axis line style={latex-latex},
    ticklabel style={font=\tiny},
     xlabel = {$M$},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel = {$N$},
    ylabel style={at={(ticklabel* cs:1)},anchor=south east}
]

\coordinate (O) at (0,0);
\node[fill=white,circle,inner sep=0pt] (O-label) at ($(O)+(-135:10pt)$) {$O$};

\addplot[color=black,domain=1.5:9,smooth,thick,-] {-3*(x-6)^2+4*x+64} node[right] (a) at (8,74){$f(x) $};
\addplot[color=red,domain=1:5,thick,-] {22*x-17} node[color=black,right] (b){$L$};
\node[fill=black,circle,scale=0.3,anchor=center] (n) at (3,49) {};
\addplot[ color=black,smooth,thick,circle] (3,49) node(P)[left] {$D(P1,f(P1))$};
\addplot[color=cyan,domain=1:9.4,smooth,thick,-] {7*x+28}node[right] (d){};
\node[fill=black,circle,scale=0.3,anchor=center] (g) at (8,84) {};
\addplot[ color=black,smooth,thick,circle] (8,84) node(P)[right] {$S(P2,f(P2))$};
\addplot[color=violet,domain=3:8,smooth,thick,-] {49}
node[pos=0.5,anchor=center,color=black,below,thick](f) {$P2-P1$};
\draw[snake=brace,mirror snake,red,thick] (3,49) -- (8,49);
\draw[color=violet,domain=8:8,thick,-] (8,49) -- (8,84)
node(yline1)[color=black,right] at (8,60) {$f(P2)-f(P1)$};
\draw[snake=brace,mirror snake,red,thick] (8,49) -- (8,84);
\draw[color=black,domain=8:8,smooth,thick,dashed] (3,0) -- (3,49) node(yline2)[below,yshift =-2.4 cm] {$P1$};
\draw[color=black,domain=8:8,smooth,thick,dashed] (8,0) -- (8,49) node(yline3)[below,yshift =-2.6 cm] {$P2$};
\end{axis}
\end{tikzpicture}
\end{document}

切线-1

答案1

这不是答案。我给出了一个简单的 TikZ 方法来得到类似的图形grid(看起来很乱)。

在此处输入图片描述

\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[x=6mm,y=.5mm]
%\draw[violet!20] (-1.5,-15) grid[xstep=1,ystep=10] (12.5,115);
\draw[->] (-1.5,0)--(12,0) node[below=1mm]{$M$};
\draw[->] (0,-15)--(0,110) node[right]{$N$};
\path (0,0) coordinate (O) node[below left]{$O$};

\draw[smooth,thick] plot[domain=1:9.2] (\x,{-3*(\x-6)^2+4*\x+64}) node[right]{$f(x)$}; 
\draw[cyan,thick] plot[domain=1:9] (\x,{7*\x+28}); 
\draw[red,thick] plot[domain=1:5.5] (\x,{22*\x-17}) node[right]{$L$}; 
\path[blue]
(3,49) coordinate (D) +(-1.2,4) node[scale=.75]{$D(p_1,f(p_1))$} 
(8,84) coordinate (S) +(1.5,-1) node[scale=.75]{$S(p_2,f(p_2))$}
(D-|S) coordinate (T);
\fill[blue] (D) circle(2pt) (S) circle(2pt);
\foreach \i in {2,4,6,10}
\draw (\i,2)--(\i,-2) node[below,fill=white]{$\i$};
\foreach \j in {20,40,...,100}
\draw (.2,\j)--(-.2,\j) node[left,fill=white]{$\j$};

\draw[violet] (D)
--(T) node[below=2mm,pos=.5]{$p_2-p_1$}
--(S) node[right=1mm,pos=.3]{$f(p_2)-f(p_1)$};
\draw[dashed,violet] 
(D)--(D|-O) node[below]{$p_1$}
(T)--(T|-O) node[below]{$p_2$};
\draw[red,decorate,decoration={brace,raise=5pt}] (T)--(D);
\draw[red,decorate,decoration={brace,raise=3pt}] (S)--(T);
\end{tikzpicture}
\end{document}

答案2

由于您的问题是关于网格和坐标轴的,以下是我从tkz-euclid手册中收集到的信息

\usepackage{tikz}
\usepackage{tkz-euclide}

\begin{document}
\begin{tikzpicture}
  \tkzInit[xmin=-2.5,xmax=12.5, ymin=-2.5,ymax=10.5]
  \tkzGrid[color=cyan]
  \tkzDrawX[thick,>=latex,label=$M$]
  \tkzDrawY[thick,>=latex,label=$N$]

  \foreach \x in {-2,2,4,...,12}
  { \tkzDefPoint(\x,0){$\x$}
    \tkzLabelPoints[below]($\x$) }
  
  \foreach \y in {-20,20,40,...,100}
  { \tkzDefPoint(0,\y/10){$\y$}
    \tkzLabelPoints[left]($\y$) }

  \tkzDefPoint(0,0){$O$}
  \tkzLabelPoints[xshift=-.5cm]($O$)
  
  
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容